After ng serve i have an errors in the console. How i can fix it?
ERROR in ./node_modules/resolve/lib/sync.js
Module not found: Error: Can't resolve 'fs' in 'project-path\node_modules\resolve\lib'
ERROR in ./node_modules/resolve/lib/async.js
Module not found: Error: Can't resolve 'fs' in 'project-path\node_modules\resolve\lib'
ERROR in ./node_modules/tslint/lib/utils.js
Module not found: Error: Can't resolve 'fs' in 'project-path\node_modules\tslint\lib'
You have to provide 2 different version of the file that uses fs
in your code, as 2 service providers, one in the server module with fs, and the other without it.
If this doesn't make much sense, check the solution details here:
https://github.com/ngx-translate/core/issues/754#issuecomment-353616515
It appears this issue is not Angular 9 specific. See examples of the problem and solutions from earlier versions of Angular here: Update to Angular v6 - Module not found: Error: Can't resolve 'fs'
It could be a problem with one of your dependencies. In this case you can try telling Webpack (which Angular uses under the hood) to ignore fs
in browser environment (non Node).
An example of this problem and the specifics of the solution can be found here: https://stackoverflow.com/a/52367183/146656
1st : step you have to take a proper backup and follow the below steps
remove node_modules
remove package-lock.json
npm cache clean -f
(Optional)If you are already done with above please restart your machine. and start node and angular again.
2nd : adding the following to karma.conf.js
webpack: { node: { fs: 'empty', } }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.