npm run server报错原因之一:Cannot find module 'webpack-cli/bin/config-yargs'
使用npm run dev启动server时报错:C:\Users\Administrator\daqixin-product\health-platform\health-wx-web>npm run dev> vue-mall@1.0.0 dev C:\Users\Administrator\daqixin-product\health-platform\healt
·
使用npm run dev启动server时报错:
C:\Users\Administrator\daqixin-product\health-platform\health-wx-web>npm run dev
> vue-mall@1.0.0 dev C:\Users\Administrator\daqixin-product\health-platform\health-wx-web
> webpack-dev-server --inline --progress --config build/webpack.dev.conf.js
The CLI moved into a separate package: webpack-cli
Please install 'webpack-cli' in addition to webpack itself to use the CLI
-> When using npm: npm i -D webpack-cli
-> When using yarn: yarn add -D webpack-cli
internal/modules/cjs/loader.js:583
throw err;
^
Error: Cannot find module 'webpack-cli/bin/config-yargs'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (C:\Users\Administrator\daqixin-product\health-platform\health-wx-web\node_modules\webpack-dev-server\bin\webpack-dev-server.js:84:1)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! vue-mall@1.0.0 dev: `webpack-dev-server --inline --progress --config build/webpack.dev.conf.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the vue-mall@1.0.0 dev 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\Administrator\product\iulicai-dev\nodejs-env\node_cache\_logs\2019-01-06T08_25_50_539Z-debug.log
原因是找不到webpack-cli这个包,咱们使用npm添加此包即可:
E:\webpack_demo>npm install webpack-cli
> webpack-cli@3.2.0 postinstall C:\Users\Administrator\daqixin-product\health-platform\health-wx-web\node_modules\webpack-cli
> opencollective postinstall
*** Thank you for using webpack-cli! ***
Please consider donating to our open collective
to help us maintain this package.
https://opencollective.com/webpack/donate
***
npm WARN less-loader@4.0.5 requires a peer of less@^2.3.1 but none is installed. You must install peer dependencies yourself.
npm WARN webpack-dev-middleware@3.4.0 requires a peer of webpack@^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN webpack-dev-server@3.1.14 requires a peer of webpack@^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN webpack-cli@3.2.0 requires a peer of webpack@4.x.x but none is installed. You must install peer dependencies yourself.
+ webpack-cli@3.2.0
added 92 packages from 68 contributors, updated 1 package and audited 10044 packages in 41.374s
found 4 moderate severity vulnerabilities
run `npm audit fix` to fix them, or `npm audit` for details
然后再执行npm run dev:
E:\webpack_demo>npm run dev
> vue-mall@1.0.0 dev C:\Users\Administrator\daqixin-product\health-platform\health-wx-web
> webpack-dev-server --inline --progress --config build/webpack.dev.conf.js
C:\Users\Administrator\daqixin-product\health-platform\health-wx-web\node_modules\ajv-keywords\keywords\instanceof.js:52
throw new Error('invalid "instanceof" keyword value ' + c);
^
Error: invalid "instanceof" keyword value Promise
at getConstructor (C:\Users\Administrator\daqixin-product\health-platform\health-wx-web\node_modules\ajv-keywords\keywords\instanceof.js:52:11)
at Ajv.compile (C:\Users\Administrator\daqixin-product\health-platform\health-wx-web\node_modules\ajv-keywords\keywords\instanceof.js:21:27)
at Object.useCustomRule (C:\Users\Administrator\daqixin-product\health-platform\health-wx-web\node_modules\ajv\lib\compile\index.js:274:26)
at Object.generate_custom [as code] (C:\Users\Administrator\daqixin-product\health-platform\health-wx-web\node_modules\ajv\lib\dotjs\custom.js:32:24)
at Object.generate_validate [as validate] (C:\Users\Administrator\daqixin-product\health-platform\health-wx-web\node_modules\ajv\lib\dotjs\validate.js:347:35)
at Object.generate_anyOf [as code] (C:\Users\Administrator\daqixin-product\health-platform\health-wx-web\node_modules\ajv\lib\dotjs\anyOf.js:34:27)
at generate_validate (C:\Users\Administrator\daqixin-product\health-platform\health-wx-web\node_modules\ajv\lib\dotjs\validate.js:347:35)
at localCompile (C:\Users\Administrator\daqixin-product\health-platform\health-wx-web\node_modules\ajv\lib\compile\index.js:87:22)
at Ajv.compile (C:\Users\Administrator\daqixin-product\health-platform\health-wx-web\node_modules\ajv\lib\compile\index.js:56:13)
at Ajv._compile (C:\Users\Administrator\daqixin-product\health-platform\health-wx-web\node_modules\ajv\lib\ajv.js:351:27)
at Ajv.compile (C:\Users\Administrator\daqixin-product\health-platform\health-wx-web\node_modules\ajv\lib\ajv.js:117:37)
at validateObject (C:\Users\Administrator\daqixin-product\health-platform\health-wx-web\node_modules\webpack\lib\validateSchema.js:36:23)
at validateSchema (C:\Users\Administrator\daqixin-product\health-platform\health-wx-web\node_modules\webpack\lib\validateSchema.js:31:10)
at processConfiguredOptions (C:\Users\Administrator\daqixin-product\health-platform\health-wx-web\node_modules\webpack-cli\bin\convert-argv.js:136:48)
at module.exports (C:\Users\Administrator\daqixin-product\health-platform\health-wx-web\node_modules\webpack-cli\bin\convert-argv.js:130:10)
at Object.<anonymous> (C:\Users\Administrator\daqixin-product\health-platform\health-wx-web\node_modules\webpack-dev-server\bin\webpack-dev-server.js:92:55)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! vue-mall@1.0.0 dev: `webpack-dev-server --inline --progress --config build/webpack.dev.conf.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the vue-mall@1.0.0 dev 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\Administrator\product\iulicai-dev\nodejs-env\node_cache\_logs\2019-01-06T08_32_43_100Z-debug.log
Error: invalid “instanceof” keyword value Promise的解决方法
我的webpack版本是3.2,webpack-dev-serverk原来版本是3.1,我将webpack-dev-serverk降版为2.9.4就可以了。指定安装命令如下:
npm install webpack-dev-server@2.9.4 --save-dev
更多推荐
已为社区贡献1条内容
所有评论(0)