2

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..

Ketan Akbari
  • 10,837
  • 5
  • 31
  • 51

3 Answers3

2

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

Anand A.S
  • 87
  • 7
0

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;

p4r1
  • 2,490
  • 16
  • 18
  • Sorry, turns out that only works with `global`. There are [multiple](https://github.com/angular/angular-cli/issues/8272) [issues](https://github.com/angular/angular-cli/issues/5324) in the angular-cli repo for this problem, but the answer seems to be "working as indended". – p4r1 May 25 '18 at 13:06
0

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.

Fateme Fazli
  • 11,582
  • 2
  • 31
  • 48