找不到模块'webpack'-Angular [英] Cannot find module 'webpack' - Angular
本文介绍了找不到模块'webpack'-Angular的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我刚刚将项目从angular v5.x迁移到v6.x,现在当我尝试使用ng serve
启动它时,我得到了:
I just migrated my project from angular v5.x to v6.x and now when I try to start it with ng serve
I'm getting:
Cannot find module 'webpack'
Error: Cannot find module 'webpack'
at Function.Module....
有什么帮助吗?
我清除了节点模块,然后:
I cleared node modules and:
-
npm cache clean --force
-
npm install
-
npm install --save-dev @angular/cli@latest
npm cache clean --force
npm install
npm install --save-dev @angular/cli@latest
但这没有帮助
推荐答案
我遇到了同样的问题,并且对我有用:
I had the same issue and this worked for me:
-
删除这些文件/文件夹(从Angular根文件夹中):
Delete these files/ folders (from your Angular root folder):
-
package-lock.json
(不是 package.json) -
/node_modules
文件夹 -
/dist
文件夹
package-lock.json
(Not the package.json)/node_modules
folder/dist
folder
执行命令(重新生成package-lock.json
和/node_modules
):
Execute command (regenerate the package-lock.json
and the /node_modules
):
-
$npm install
现在一切正常,是package-lock.json
导致npm下载旧版本的依赖项.
Everything should work now, it was the package-lock.json
that caused npm to download old versions of dependencies.
这篇关于找不到模块'webpack'-Angular的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文