-
Notifications
You must be signed in to change notification settings - Fork 12k
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
ng build not working with dependency to npm module csvtojson #10694
Comments
I am running into a similar issue with exceljs. I installed browserify versions of the node libraries with errors: browserify-fs, browserify-os, path-browserify, stream-browserify, Then in tsconfig.json I added them in as paths:
This allows the project to build and run (the paths depend on the baseUrl property). However, I am still running into some errors with ng test: If I remove the paths above then ng test works. So I'm in the awkward position of having either ng build work (with paths) or ng test work (without paths). I've tried playing around with the tsconfig.spec.json file to remove these paths for testing, but haven't had any luck so far. |
After migrating our project from Angular 5.2 to 6.1 we suddenly have similar issues regarding packages imported from node_modules. We use minimatch 3.0.4 and get the following error:
We have tried to troubleshoot this as much as we can and can't really find any problems with our project as this worked flawlessly before we migrated. We tried to replace the minimatch with micromatch to see if that made any difference, but the problem is also present there. |
This is because in latest angular-cli, node.js globals and modules polyfills and mocks are removed. see Line 117 in 0cfbdbc
You can find polyfills and mocks in node-libs-browser. For node.js builtin modules, see @jmac-slash0's answer above. For builtin global variables, you can add the corresponding mock to your import * as process from 'node-libs-browser/mock/process';
(<any>window).process = process; But the permanent, correct way to resolve this is to avoid including packages that aren't designed to run in browser environment. |
The ultimate fix for me was to remove the browserify versions of the node libraries, and instead add the correct browser library file to the path in
I assume a similar strategy could work for csvtojson, maybe something like:
|
Glad to see you fixed and thank for inspiring me. Not every library provides browser implementation though. For me it's micromatch that caused the problem and we have other problem to replace it. I'm pretty sure in our usage, |
@s25g5d4's answer (#10694 (comment)) is accurate. There is more information on why we removed the node globals in #9827 (comment). |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Versions
Repro steps
csvtojson
and@types/csvtojson
to package.json and runnpm install
Observed behavior
When running
ng build
, the output isDesired behavior
It should build without error, as it did with Angular CLI 1.7.4
The text was updated successfully, but these errors were encountered: