React|React In Action · 工具链 · webpack Cannot find module 'webpack-cli/bin/config-yargs'

一、npm start 异常 D:\CodePractice\2021\00_BoilerPlate>npm start
> 00_boilerplate@1.0.0 start D:\CodePractice\2021\00_BoilerPlate
> webpack-dev-server--mode development --inline --hot --open
internal/modules/cjs/loader.js:589
throw err;
^
Error: Cannot find module 'webpack-cli/bin/config-yargs'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:587:15)
at Function.Module._load (internal/modules/cjs/loader.js:513:25)
at Module.require (internal/modules/cjs/loader.js:643:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object. (D:\CodePractice\2021\00_BoilerPlate\node_modules\webpack-dev-server\bin\webpack-dev-server.js:65:1)
at Module._compile (internal/modules/cjs/loader.js:707:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:718:10)
at Module.load (internal/modules/cjs/loader.js:605:32)
at tryModuleLoad (internal/modules/cjs/loader.js:544:12)
at Function.Module._load (internal/modules/cjs/loader.js:536:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! 00_boilerplate@1.0.0 start: `webpack-dev-server--mode development --inline --hot --open`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the 00_boilerplate@1.0.0 start 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\sinwaj\AppData\Roaming\npm-cache\_logs\2021-03-21T07_26_42_987Z-debug.log
二、package.json版本信息
"dependencies": {
"webpack-cli": "^4.5.0",
"webpack-dev-server": "^3.11.2"
}
三、降级webpack-cli 4.5.0降级到3.3.12
1.D:\CodePractice\2021\00_BoilerPlate>npm uninstall webpack-cli
2.D:\CodePractice\2021\00_BoilerPlate>npm install webpack-cli@^3.3.12
四、重新启动 D:\CodePractice\2021\00_BoilerPlate>npm start
> 00_boilerplate@1.0.0 start D:\CodePractice\2021\00_BoilerPlate
> webpack-dev-server--mode development --inline --hot --open
i ?wds?: Project is running at http://localhost:8080/
i ?wds?: webpack output is served from /
i ?wds?: Content not from webpack is served from ./dist
i ?atl?: Using typescript@4.2.3 from typescript
i ?atl?: Using tsconfig.json from D:/CodePractice/2021/00_BoilerPlate/tsconfig.json
【React|React In Action · 工具链 · webpack Cannot find module 'webpack-cli/bin/config-yargs'】WARNING (@babel/preset-env): We noticed you're using the `useBuiltIns` option without declaring a core-js version. Currently, we assume version 2.x when no version is passed. Since this default version will likely change in future versions of Babel, we recommend explicitly setting the core-js version you are using via the `corejs` option.
You should also be sure that the version you pass to the `corejs` option matches the version specified in your `package.json`'s `dependencies` section. If it doesn't, you need to run one of the following commands:
npm install --save core-js@2npm install --save core-js@3
yarn add core-js@2yarn add core-js@3
More info about useBuiltIns: https://babeljs.io/docs/en/babel-preset-env#usebuiltins
More info about core-js: https://babeljs.io/docs/en/babel-preset-env#corejs
i ?wdm?: wait until bundle finished: /
i ?atl?: Checking started in a separate process...
i ?atl?: Time: 717ms
i ?wdm?: Compiled successfully.

    推荐阅读