{"record":{"id":"83439c355704ef81","repo":"angular/angular","slug":"missing-jsonp-module","errorCode":"MISSING_JSONP_MODULE","errorMessage":"Cannot make a JSONP request without JSONP support. To fix the problem, either add the `withJsonpSupport()` call (if `provideHttpClient()` is used) or import the `HttpClientJsonpModule` in the root NgModule.","messagePattern":"Cannot make a JSONP request without JSONP support\\. To fix the problem, either add the `withJsonpSupport\\(\\)` call \\(if `provideHttpClient\\(\\)` is used\\) or import the `HttpClientJsonpModule` in the root NgModule\\.","errorType":"error_code","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"packages/common/http/src/xhr.ts","lineNumber":128,"sourceCode":"    optional: true,\n  });\n\n  constructor(private xhrFactory: XhrFactory) {}\n\n  private maybePropagateTrace<T extends Function>(fn: T): T {\n    return this.tracingService?.propagate ? this.tracingService.propagate(fn) : fn;\n  }\n\n  /**\n   * Processes a request and returns a stream of response events.\n   * @param req The request object.\n   * @returns An observable of the response events.\n   */\n  handle(req: HttpRequest<any>): Observable<HttpEvent<any>> {\n    // Quick check to give a better error message when a user attempts to use\n    // HttpClient.jsonp() without installing the HttpClientJsonpModule\n    if (req.method === 'JSONP') {\n      throw new RuntimeError(\n        RuntimeErrorCode.MISSING_JSONP_MODULE,\n        (typeof ngDevMode === 'undefined' || ngDevMode) &&\n          `Cannot make a JSONP request without JSONP support. To fix the problem, either add the \\`withJsonpSupport()\\` call (if \\`provideHttpClient()\\` is used) or import the \\`HttpClientJsonpModule\\` in the root NgModule.`,\n      );\n    }\n\n    // Validate that the request is compatible with the XHR backend.\n    ngDevMode && validateXhrCompatibility(req);\n\n    // Check whether this factory has a special function to load an XHR implementation\n    // for various non-browser environments. We currently limit it to only `ServerXhr`\n    // class, which needs to load an XHR implementation.\n    const xhrFactory: XhrFactory & {ɵloadImpl?: () => Promise<void>} = this.xhrFactory;\n    const source: Observable<void | null> =\n      // Note that `ɵloadImpl` is never defined in client bundles and can be\n      // safely dropped whenever we're running in the browser.\n      // This branching is redundant.\n      // The `ngServerMode` guard also enables tree-shaking of the `from()`","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/angular/angular/blob/51cb07e98081ab7e4e84a9e0949266a8e19cca84/packages/common/http/src/xhr.ts#L110-L146","documentation":"Thrown by XhrBackend.handle when it receives a request with method 'JSONP'. XhrBackend is the default backend and cannot perform JSONP (which needs script-tag injection and a dedicated backend); a JSONP request reaching it means the JSONP support that reroutes such requests to JsonpClientBackend was never installed. The message tells you exactly which registration is missing for your setup style.","triggerScenarios":"Calling http.jsonp(url, 'cb') after provideHttpClient(...) without withJsonpSupport(); using NgModule-based HttpClientModule (which defaults to XhrBackend) without importing HttpClientJsonpModule; registering withJsonpSupport() on a different injector than the one issuing the request.","commonSituations":"Migrating from HttpClientModule to provideHttpClient and dropping the JsonpModule import; enabling provideHttpClient in a lazy route but adding withJsonpSupport() only in the root; hitting a legacy JSONP endpoint after an Angular upgrade. JSONP is deprecated since 22.1, so ideally migrate the endpoint.","solutions":["If using provideHttpClient: add withJsonpSupport() to the same provideHttpClient(...) call that provides HttpClient for the code making the request","If using NgModules: import HttpClientJsonpModule alongside HttpClientModule in the root NgModule","Verify the feature is registered in the injector that serves the component calling http.jsonp() (not a sibling/lazy injector)","Consider replacing the JSONP endpoint with a CORS-enabled normal request — JSONP is deprecated and XSS-prone"],"exampleFix":"// before\nprovideHttpClient(withFetch(), withInterceptors([authInterceptor]));\n// ...\nhttp.jsonp('https://api.example.com/data', 'cb'); // throws MISSING_JSONP_MODULE\n\n// after\nprovideHttpClient(withFetch(), withInterceptors([authInterceptor]), withJsonpSupport());","handlingStrategy":"try-catch","validationCode":"// fail fast before issuing JSONP if support is missing (dev aid)\nimport {JsonpClientBackend} from '@angular/common/http';\nfunction jsonpSupportRegistered(): boolean {\n  return inject(JsonpClientBackend, {optional: true}) !== null;\n}","typeGuard":null,"tryCatchPattern":"http.jsonp<unknown>(url, 'cb').subscribe({\n  next: handleData,\n  error: (err) => {\n    if (err instanceof Error && err.message.includes('without JSONP support')) {\n      // registration bug: add withJsonpSupport() / HttpClientJsonpModule\n      console.error('JSONP support is not registered — fix provideHttpClient setup');\n    } else {\n      handleFailure(err);\n    }\n  },\n});","preventionTips":["Add withJsonpSupport() in the same provideHttpClient call (or HttpClientJsonpModule beside HttpClientModule) as a build-time convention","Wrap all JSONP usage in one service so registration gaps surface in one place","Prefer migrating endpoints to CORS + http.get(); JSONP is deprecated"],"tags":["http","jsonp","dependency-injection","setup"],"backgroundTag":"missing-module-import","analyzedSha":"51cb07e98081ab7e4e84a9e0949266a8e19cca84","analyzedAt":"2026-08-22T07:04:54.531Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}