Skip to content

http and https module issue with angular 18.2 #372

Open
@ashishsharma229

Description

@ashishsharma229

I am trying to upgrade my angular application from angular 16 to angular 18. This @apidevtools/json-schema-ref-parser is coming from swagger-parser in my application and i am using v10.0.3 of it.

I updated @angular-devkit/build-angular to 18.2.8 version. When i am trying to serve the application using ng serve command i am getting following error

✘ [ERROR] Could not resolve "http"

    node_modules/@apidevtools/json-schema-ref-parser/lib/resolvers/http.js:3:21:
      3 │ const http = require("http");
        ╵                      ~~~~~~

  The package "http" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.


✘ [ERROR] Could not resolve "https"

    node_modules/@apidevtools/json-schema-ref-parser/lib/resolvers/http.js:4:22:
      4 │ const https = require("https");
        ╵                       ~~~~~~~

  The package "https" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

I already added http and https in browser list in package.json but as expected it is not helping at all.

"browser": {
  "fs": false,
  "path": false,
  "os": false,
  "process": false,
  "crypto": false,
  "http": false,
  "https": false
}

My few Angular dependencies are

"@angular/animations": "18.2.8",
"@angular/cdk": "18.2.8",
"@angular/common": "18.2.8",
"@angular/compiler": "18.2.8",
"@angular/core": "18.2.8",
"@angular/elements": "18.2.8",
"@angular/forms": "18.2.8",
"@angular/localize": "18.2.8",
"@angular/platform-browser": "18.2.8",
"@angular/platform-browser-dynamic": "18.2.8",
"@angular/router": "18.2.8",
"http-browserify": "^1.7.0",
"https-browserify": "^1.0.0",
"crypto-browserify": "^3.12.0",
"swagger-parser": "10.0.3",

and few dev-dependencies

"@angular-devkit/build-angular": "18.2.8",
"@angular-devkit/core": "18.2.8",
"@angular-devkit/schematics": "18.2.8",
"@angular-eslint/builder": "18.3.0",
"@angular-eslint/eslint-plugin": "18.3.0",
"@angular-eslint/eslint-plugin-template": "18.3.0",
"@angular-eslint/schematics": "18.3.0",
"@angular-eslint/template-parser": "18.3.0",
"@angular/cli": "18.2.8",
"@angular/compiler-cli": "18.2.8",
"@angular/language-service": "18.2.8",
"stream-browserify": "^3.0.0",

Can someone please help?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions