Cannot find module 'webpack' - Angular

前端 未结 4 1972
醉话见心
醉话见心 2020-12-08 10:12

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\'
E         


        
相关标签:
4条回答
  • 2020-12-08 10:41

    Try to see if this works...

    npm uninstall --save webpack
    npm install --save-dev webpack
    
    0 讨论(0)
  • 2020-12-08 10:48

    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
    
    0 讨论(0)
  • 2020-12-08 10:54

    I fixed this issue with:

    delete package-lock.json
    delete node_modules
    delete dist (if exist)
    
    npm cache clean --force
    
    npm install
    
    0 讨论(0)
  • 2020-12-08 10:56

    I had the same issue and this worked for me:

    1. Delete these files/ folders (from your Angular root folder):

      • package-lock.json (Not the package.json)
      • /node_modules folder
      • /dist folder
    2. 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.

    0 讨论(0)
提交回复
热议问题