运行node.js时报如下错误:
ERROR in ./node_modules/@marko/compiler/dist/config.js 1:182-195
Module not found: Error: Can't resolve 'fs' in '/home/xd/work/coding/nodejs/StockResearchApp/node_modules/@marko/compiler/dist'ERROR in ./node_modules/lasso-caching-fs/src/index.js 1:9-22
Module not found: Error: Can't resolve 'fs' in '/home/xd/work/coding/nodejs/StockResearchApp/node_modules/lasso-caching-fs/src'ERROR in ./node_modules/lasso-caching-fs/src/index.js 3:15-30
Module not found: Error: Can't resolve 'path' in '/home/xd/work/coding/nodejs/StockResearchApp/node_modules/lasso-caching-fs/src'BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }'
- install 'path-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "path": false }ERROR in ./node_modules/lasso-package-root/src/index.js 1:15-30
Module not found: Error: Can't resolve 'path' in '/home/xd/work/coding/nodejs/StockResearchApp/node_modules/lasso-package-root/src'BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }'
- install 'path-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "path": false }browser (webpack 5.88.2) compiled with 4 errors in 2840 ms
解决方法:
在webpack.config.js中如下设置:
resolve: { fallback: { "fs": false, "path": false, } }