react 启动异常 & 代码未做任何改动 =》怀疑安装elint时包有问题
错误日志:
\jsx> yarn start
yarn run v1.19.1
$ node ./YarnStartPreCheck.js && react-app-rewired start
internal/modules/cjs/loader.js:797
throw err;
^
Error: Cannot find module 'webpack/lib/node/NodeTemplatePlugin'
Require stack:
- D:………………\jsx\node_modules\html-webpack-plugin\lib\compiler.js
- D:………………\jsx\node_modules\html-webpack-plugin\index.js
- D:………………\jsx\node_modules\react-scripts\config\webpack.config.js
- D:………………\jsx\node_modules\react-app-rewired\scripts\start.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 Object.<anonymous> (D:………………\jsx\node_modules\html-webpack-plugin\lib\compiler.js:14:28)
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) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'D:\\……………………\\jsx\\node_modules\\html-webpack-plugin\\lib\\compiler.js',
'D:\\………………\\jsx\\node_modules\\html-webpack-plugin\\index.js',
'D:\\………………\\jsx\\node_modules\\react-scripts\\config\\webpack.config.js',
'D:\\………………\\jsx\\node_modules\\react-app-rewired\\scripts\\start.js'
]
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
撤销代码修改、配置修改,yarn start,错误同上(非代码、配置问题)
重新安装yarn: yarn install,错误同上(非 yarn版本问题)。
查找.gitignore文件:
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. # dependencies /node_modules /dist /__MOCK__ /.pnp .pnp.js /src/index.js # testing /coverage # production /build # misc .DS_Store .env.local .env.development.local .env.test.local .env.production.local npm-debug.log* yarn-debug.log* yarn-error.log* yarn.lock
删除文件夹:node_modules & dist
重新安装yarn: yarn install (yarn install //安装package.json里所有包,并将包及它的所有依赖项保存进yarn.lock)
重新运行:成功 (maybe:包安装冲突 or 包缺失)

浙公网安备 33010602011771号