Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incompatible with angular >= 6.0.0 #129

Closed
cdyue opened this issue Jun 28, 2019 · 11 comments
Closed

incompatible with angular >= 6.0.0 #129

cdyue opened this issue Jun 28, 2019 · 11 comments

Comments

@cdyue
Copy link

cdyue commented Jun 28, 2019

Subject of the issue

Because json-schema-ref-parser requires node http & https, it cannot be used in Angular applications that use angular-cli >= 6.0.0

See this comment from angular-cli:
angular/angular-cli#9827 (comment)

Your environment

angular>= 6.0

Expected behavior

I can use json-schema-ref-parser in my app and ng serve does not fail

Actual behavior

ng serve fails with

ERROR in ./node_modules/json-schema-ref-parser/lib/resolvers/http.js
Module not found: Error: Can't resolve 'http' in '/Users/web/container-web/node_modules/json-schema-ref-parser/lib/resolvers'
ERROR in ./node_modules/json-schema-ref-parser/lib/resolvers/http.js
Module not found: Error: Can't resolve 'https' in '/Users/web/container-web/node_modules/json-schema-ref-parser/lib/resolvers'
@cdyue cdyue changed the title Unified incompatible with angular >= 6.0.0 incompatible with angular >= 6.0.0 Jun 28, 2019
@JamesMessinger
Copy link
Member

Good point. I'd happily accept a PR that switched the http resolver from http and https to a browser-compatible library such as node-fetch

@Bakerburgh
Copy link

For anyone interested in a quick workaround for Angular, I made this fork where I removed the HTTP(S) feature.

I modified the README to include directions for publishing it to a local NPM repository via Verdaccio and some other steps you need to take inside your Angular app. (See this SO answer).

This fork is not a good starting point for a PR. It's just a hacky workaround for those that don't need to resolve HTTP(s) references.

@rlyttle
Copy link

rlyttle commented Aug 29, 2019

I'm facing the same issue here.

@Bakerburgh I've tried your fork, but getting the following error - could you possibly provide a little guidance here? I've checked the project out and npm installed it into my own project from a local directory rather than via a local npm registry.

ERROR in ../json-schema-ref-parser/lib/util/url.js Module not found: Error: Can't resolve 'url' in '/Users/rr/git/testproj/json-schema-ref-parser/lib/util' ℹ 「wdm」: Failed to compile.

[EDIT] My bad - I forgot to run npm install within the json-schema-ref-parser module. More or less working now, Thanks for your fork!

@sarathsnair
Copy link

Hi,

I am also facing this issue. I am using Angular 8 and SwaggerParser is failing because of this. In my scenario, I can't use the hacky solution due to some constraints.

@fricci
Copy link

fricci commented May 5, 2020

same here, I'm using Angular 9 and json-schema-ref-parse 9.0.1 but I get the same error.

@tmalatinszki
Copy link

Hi,

Same here... :( Are there any plans to fix this issue in the near future?

Regards,
Tamás

@laneschmidt
Copy link

still getting this while using angular 9, no fix that i can find

@philsturgeon
Copy link
Member

Is there one of you people in here who would send a PR? This is a free tool, and people experiencing problems are often the best people to be solving those problems. Otherwise you're asking somebody to carve time out of their day to fix something that they don't need for their personal projects, or their day job, or anything else, other than helping folks out.

People do like helping folks out, but there are lots of other folks wanting help with lots of other things, so... maybe somebody here could step up and take a go at the suggestion James made last year?

Good point. I'd happily accept a PR that switched the http resolver from http and https to a browser-compatible library such as node-fetch

@TimUnderhay
Copy link

For those who don't require resolution of external references, it shouldn't be a requirement at all to load any http module, which causes needless bundle bloat. It should be optional.

@johnzondr
Copy link

johnzondr commented Feb 12, 2021

i got it working, add this to package.json & reinstall:

"browser": { "http": false, "https": false }

and add this to polyfill.ts

(window as any).process = require('process/browser');
(window as any).global = window;

@philsturgeon
Copy link
Member

If this still needs fixing please do send a PR, otherwise I am glad we have a workaround! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests