在安装了webpack4和webpack-cli时找不到config-yargs

时间:2018-07-12 15:20:23

标签: typescript webpack vue.js

创建新的VueJS项目(带有TypeScript,ans Single Files Components类)后,使用npm run dev启动它时出现错误。我在不同的主题上看到您需要安装webpack-cli,所以我安装了它,但是我仍然遇到相同的错误:

Error: Cannot find module 'webpack/bin/config-yargs'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (C:\Users\tozenda\Documents\SEC\testlearning\learning\ElectriCar.WebSite\electricar.website\node_modules\webpack-dev-server\bin\webpack-dev-server.js:54:1)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)

这是我package.json的一部分:

"scripts": {
    "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
    "start": "npm run dev",
    "lint": "eslint --ext .js,.vue src",
    "build": "node build/build.js"},
[...]
"devDependencies": {
    [...]
    "webpack": "^4.16.0",
    "webpack-bundle-analyzer": "^2.9.0",
    "webpack-cli": "^3.0.8",
    "webpack-dev-server": "^2.9.1",
    "webpack-merge": "^4.1.0"
  },

您有解决方案吗?

谢谢

更新:我试图降级到webpack 3.12.0,但是ts-loader要求使用webpack 4 ...

1 个答案:

答案 0 :(得分:0)

解决方案:

由于npm update不会更新所有软件包,所以就是问题所在。

我使用npm-update-all更新了所有软件包。这解决了我的问题。