Node.js / npm:在开发模式下运行时找不到模块

时间:2018-04-29 08:00:14

标签: node.js npm webpack

运行npm run dev时,收到以下错误消息:

Error: Cannot find module 'webpack/bin/config-yargs'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:571:15)
    at Function.Module._load (internal/modules/cjs/loader.js:497:25)
    at Module.require (internal/modules/cjs/loader.js:626:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (C:\Users\Isabelle\coursetro-eth\node_modules\webpack-dev-server\bin\webpack-dev-server.js:54:1)
    at Module._compile (internal/modules/cjs/loader.js:678:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:689:10)
    at Module.load (internal/modules/cjs/loader.js:589:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:528:12)
    at Function.Module._load (internal/modules/cjs/loader.js:520:3) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! coursetro-eth@1.0.0 dev: `webpack-dev-server --config build/webpack.dev.conf.js` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the coursetro-eth@1.0.0 dev script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

我的环境如下:

OS: Windows 10
NPM: Version 5.6.0
WebPack: Version 4.6

我的package.json文件:

{
   "name":"coursetro-eth",
   "version":"1.0.0",
   "main":"index.js",
   "scripts":{
      "dev":"webpack-dev-server --config build/webpack.dev.conf.js",
      "publish":"ngc -p tsconfig-aot.json",
      "test":"echo \"Error: no test specified\" && exit 1"
   },
   "author":"",
   "license":"ISC",
   "description":"",
   "dependencies":{
      "web3":"github:ethereum/web3.js"
   },
   "devDependencies":{
      "lite-server":"^2.3.0",
      "webpack":"^4.6.0",
      "webpack-cli":"^2.0.15",
      "webpack-dev-server":"^2.11.2",
      "webpack-validator":"^2.3.0"
   }
}

这个错误是什么?

0 个答案:

没有答案