欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Cannot find module 'webpack'

程序员文章站 2022-06-01 12:45:25
...

npm run dev,报错,昨天还运行好好的,然后执行了 git clean xfd, 然后本地无法启动

> node build/dev-server.js

internal/modules/cjs/loader.js:651
    throw err;
    ^

Error: Cannot find module 'webpack'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:649:15)
    at Function.Module._load (internal/modules/cjs/loader.js:575:25)
    at Module.require (internal/modules/cjs/loader.js:705:19)
    at require (internal/modules/cjs/helpers.js:14:16)
    at Object.<anonymous> (/Users/jiang/Documents/2019/项目/探索中心/code/bdcsc2x-portal-backend-page/build/dev-server.js:1:15)
    at Module._compile (internal/modules/cjs/loader.js:799:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:810:10)
    at Module.load (internal/modules/cjs/loader.js:666:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:606:12)
    at Function.Module._load (internal/modules/cjs/loader.js:598:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] dev: `node build/dev-server.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/jiang/.npm/_logs/2019-10-15T02_48_55_006Z-debug.log

解决方法:
1、首先我打开其他项目,是可以直接运行的
2、然后我本地yarn,重新安装了下包,然后就可以了。
3、git clean xfd(命令慎用),导致git目录下未被git跟踪的所有文件和目录被删除。