当前位置: 代码迷 >> 综合 >> npm启动项目npm run serve时报错Error: Cannot find module ‘webpack‘ 问题解决办法
  详细解决方案

npm启动项目npm run serve时报错Error: Cannot find module ‘webpack‘ 问题解决办法

热度:146   发布时间:2023-09-19 19:30:56.0

先安装cnpm后使用 cnpm i 安装包时卡顿然后强制结束下载后再次接着安装node_modules后报错error,启动项目时npm run serve报下面的错,

正确做法:如果强制中断下载后,应将node_modules删除后重新安装即可,安装结束后没有出现error说明成功

PS D:\code\DA_svn\pages\index> npm run serve

> dmpd@0.1.0 serve D:\code\DA_svn\pages\index

vue-cli-service serve

 INFO  Starting development server...
 ERROR  Error: Cannot find module 'webpack'
 Require stack:
- D:\code\DA_svn\pages\index\node_modules\_webpack-dev-server@3.11.2@webpack-dev-server\lib\Server.js     
- D:\code\DA_svn\pages\index\node_modules\_@vue_cli-service@3.12.1@@vue\cli-service\lib\commands\serve.js
- D:\code\DA_svn\pages\index\node_modules\_@vue_cli-service@3.12.1@@vue\cli-service\lib\Service.js        
- D:\code\DA_svn\pages\index\node_modules\_@vue_cli-service@3.12.1@@vue\cli-service\bin\vue-cli-service.js
Error: Cannot find module 'webpack'
Require stack:
- D:\code\DA_svn\pages\index\node_modules\_webpack-dev-server@3.11.2@webpack-dev-server\lib\Server.js
- D:\code\DA_svn\pages\index\node_modules\_@vue_cli-service@3.12.1@@vue\cli-service\lib\commands\serve.js       
- D:\code\DA_svn\pages\index\node_modules\_@vue_cli-service@3.12.1@@vue\cli-service\lib\Service.js
- D:\code\DA_svn\pages\index\node_modules\_@vue_cli-service@3.12.1@@vue\cli-service\bin\vue-cli-service.js      
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:794:15)
    at Function.Module._load (internal/modules/cjs/loader.js:687:27)
    at Module.require (internal/modules/cjs/loader.js:849:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Module._compile (internal/modules/cjs/loader.js:956:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
    at Module.load (internal/modules/cjs/loader.js:812:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Module.require (internal/modules/cjs/loader.js:849:19)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! dmpd@0.1.0 serve: `vue-cli-service serve`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the dmpd@0.1.0 serve script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\pactera\AppData\Roaming\npm-cache\_logs\2021-03-09T00_59_46_004Z-debug.log

 

  相关解决方案