Getting error while ng serve. Using mapbox/mapbox-gl-draw

460 views Asked by At

Have following versions:

"angular": 6.0.3 
"rxjs": "^6.2.0",
"@mapbox/mapbox-gl-draw": "^1.0.4",

While ng serve Getting error: enter image description here

Could anyone help me out, will be appreciated..

3

There are 3 answers

1
p4r1 On

The issue here is that Angular CLI v6 no longer ships with support for node built-in modules, see here. This fix is outlined in a comment further down the issue thread here:

In polyfills.ts add:

(window as any).fs = window;

4
Fatemeh Fazli On

actually a way to resolve this issue was ignoring the fs require in webpack.config.js but in angular-cli version 6 and upper we can't eject webpack.config.js based on this issue and issue.so we can't say webpack to ignore fs.it seems we can't use fs anymore in Angular-cli 6 and upper.You can declare the fs also by doing declare var fs: any;this solves ng serve but if you build the project then run npm run serve, will face the error:

'fs' is not defined.

0
Anand A.S On

This seems to have something to do with angular-cli. Try adding this to the package.json

"browser": { "fs": false, "path": false, "os": false }

Git issue for further details