找不到模块角度
Posted
技术标签:
【中文标题】找不到模块角度【英文标题】:Module not found angular 【发布时间】:2022-01-21 13:15:27 【问题描述】:在我将 Angular 项目从 12 版本更新到 13 版本后,我在运行 ng serve --o 时遇到了很多模块错误。我该如何解决?
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: "util": require.resolve("util/") '
- install 'util'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: "util": false
./node_modules/cacache/lib/util/tmp.js:6:13-28 - Error: Module not found: Error: Can't resolve 'path' in 'D:\StudenBook\node_modules\cacache\lib\util'
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
./node_modules/cacache/lib/verify.js:3:13-28 - Error: Module not found: Error: Can't resolve 'util' in 'D:\StudenBook\node_modules\cacache\lib'
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: "util": require.resolve("util/") '
- install 'util'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: "util": false
./node_modules/cacache/lib/verify.js:8:11-24 - Error: Module not found: Error: Can't resolve 'fs' in 'D:\StudenBook\node_modules\cacache\lib'
./node_modules/cacache/lib/verify.js:12:13-28 - Error: Module not found: Error: Can't resolve 'path' in 'D:\StudenBook\node_modules\cacache\lib'
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
./node_modules/cacache/rm.js:3:13-28 - Error: Module not found: Error: Can't resolve 'util' in 'D:\StudenBook\node_modules\cacache'
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: "util": require.resolve("util/") '
- install 'util'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: "util": false
./node_modules/cacache/rm.js:7:13-28 - Error: Module not found: Error: Can't resolve 'path' in 'D:\StudenBook\node_modules\cacache'
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
./node_modules/chownr/chownr.js:2:11-24 - Error: Module not found: Error: Can't resolve 'fs' in 'D:\StudenBook\node_modules\chownr'
./node_modules/chownr/chownr.js:3:13-28 - Error: Module not found: Error: Can't resolve 'path' in 'D:\StudenBook\node_modules\chownr'
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
./node_modules/detect-libc/lib/detect-libc.js:3:15-37 - Error: Module not found: Error: Can't resolve 'os' in 'D:\StudenBook\node_modules\detect-libc\lib'
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: "os": require.resolve("os-browserify/browser") '
- install 'os-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: "os": false
./node_modules/detect-libc/lib/detect-libc.js:4:16-50 - Error: Module not found: Error: Can't resolve 'child_process' in 'D:\StudenBook\node_modules\detect-libc\lib'
./node_modules/detect-libc/lib/detect-libc.js:5:18-43 - Error: Module not found: Error: Can't resolve 'fs' in 'D:\StudenBook\node_modules\detect-libc\lib'
./node_modules/fs-minipass/index.js:4:11-24 - Error: Module not found: Error: Can't resolve 'fs' in 'D:\StudenBook\node_modules\fs-minipass'
./node_modules/fs.realpath/index.js:8:9-22 - Error: Module not found: Error: Can't resolve 'fs' in 'D:\StudenBook\node_modules\fs.realpath'
./node_modules/fs.realpath/old.js:22:17-32 - Error: Module not found: Error: Can't resolve 'path' in 'D:\StudenBook\node_modules\fs.realpath'
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
./node_modules/fs.realpath/old.js:24:9-22 - Error: Module not found: Error: Can't resolve 'fs' in 'D:\StudenBook\node_modules\fs.realpath'
./node_modules/gauge/lib/error.js:2:11-26 - Error: Module not found: Error: Can't resolve 'util' in 'D:\StudenBook\node_modules\gauge\lib'
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: "util": require.resolve("util/") '
- install 'util'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: "util": false
./node_modules/glob/common.js:13:11-26 - Error: Module not found: Error: Can't resolve 'path' in 'D:\StudenBook\node_modules\glob'
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
./node_modules/glob/glob.js:43:9-22 - Error: Module not found: Error: Can't resolve 'fs' in 'D:\StudenBook\node_modules\glob'
./node_modules/glob/glob.js:49:11-26 - Error: Module not found: Error: Can't resolve 'path' in 'D:\StudenBook\node_modules\glob'
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
./node_modules/glob/glob.js:50:13-30 - Error: Module not found: Error: Can't resolve 'assert' in 'D:\StudenBook\node_modules\glob'
还有更多其他模块错误...请帮助我
【问题讨论】:
阅读错误信息,然后在您喜欢的搜索引擎上搜索错误信息,发现这是其他人之前看到的内容,然后采取措施纠正问题。故障排除的基础知识,真的。 ***.com/questions/64402821/… 所以,我发现了我的问题;所有故障排除都是因为 bcrypt 模块,我将其删除。我之前安装过。不知道为什么会引起这么多麻烦 【参考方案1】:您可能需要使用 npm install 来安装所有丢失的模块
例如对于您的 util 模块错误,请使用此命令重新安装 再来一次:
npm i util
【讨论】:
那么,我不能同时安装所有这些? 使用这个命令:npm i --force 我试过了,但没有。我会尝试单独安装每个模块 我希望它有效以上是关于找不到模块角度的主要内容,如果未能解决你的问题,请参考以下文章
错误:找不到模块'@ckeditor/ckeditor5-build-classic'角度9的声明文件
从 5 到 6 的角度迁移后无法构建 - 找不到模块“打字稿”