I just migrated my project from angular v5.x to v6.x and now when I try to start it with ng serve<\/code> I'm getting:
Cannot find module 'webpack'
Error: Cannot find module 'webpack'
at Function.Module....
I had the same issue and this worked for me:
Delete these files/ folders (from your Angular root folder):
package-lock.json
( Not the package.json) /node_modules
folder /dist
folder Execute command (regenerate the package-lock.json
and the /node_modules
):
$npm install
Everything should work now, it was the package-lock.json
that caused npm to download old versions of dependencies.
I fixed this issue with:
delete package-lock.json
delete node_modules
delete dist (if exist)
npm cache clean --force
npm install
This error mostly occurs because of old dependencies , if at all are not upgraded then it can be deleted manually by deleting the node_modules
Folder and also the package-lock.json
file
after that you can clean the Cache (if at all necessary) and then
npm cache clean --force
npm install
ng update @angular/cli @angular/core
使用npm link webpack
在本地工作时,在我的 CI(GitHub 操作)上,我遇到了同样的问题,为了解决它,我使用了:
npm i --save-dev webpack
npm update --force
解决了我的问题
Try to see if this works...
npm uninstall --save webpack
npm install --save-dev webpack
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.