Webpack package.json没有运行

时间:2018-06-13 12:13:30

标签: webpack

前段时间我在项目中使用了webpack,当我必须更新项目前端,并从package.json运行脚本时,我得到以下错误,所以我不能做任何事情:

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 install webpack-cli -D
-> When using yarn: yarn add webpack-cli -D
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sh@1.0.0 surveiller: `webpack --watch`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the sh@1.0.0 surveiller script.
npm ERR! This is probably not a problem with npm. There is likely 
additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you 
mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/XXX/.npm/_logs/2018-06-13T12_03_33_398Z- 
debug.log



 ///// HERE IS MY package.json CONTENT
{
      "name": "sh",
      "version": "1.0.0",
      "description": "",
      "main": "index.js",
      "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1",
        "start": "webpack-dashboard",
        "dev": "webpack",
        "surveiller": "webpack --watch",
        "prod": "cross-env NODE_ENV=production webpack --progress"
      },
      "keywords": [],
      "author": "",
      "license": "ISC",
      "devDependencies": {
        "autoprefixer": "^7.2.5",
        "babel": "^6.23.0",
        "babel-core": "^6.26.0",
        "babel-loader": "^7.1.2",
        "babel-plugin-syntax-dynamic-import": "^6.18.0",
        "babel-preset-es2015": "^6.24.1",
        "cross-env": "^5.1.3",
        "css-loader": "^0.28.9",
        "extract-text-webpack-plugin": "^3.0.2",
        "file-loader": "^1.1.6",
        "gsap": "^1.20.3",
        "node-sass": "^4.7.2",
        "optimize-css-assets-webpack-plugin": "^3.2.0",
        "postcss-loader": "^2.0.10",
        "sass-loader": "^6.0.6",
        "scrollmagic": "^2.0.5",
        "style-loader": "^0.19.1",
        "uglifyjs-webpack-plugin": "^1.1.8",
        "url-loader": "^0.6.2",
        "webpack": "^3.10.0",
        "webpack-cli": "^2.1.4",
        "webpack-dashboard": "^1.1.1",
        "webpack-dev-server": "^2.11.1"
      },
      "dependencies": {
        "base64-inline-loader": "^1.1.0",
        "imports-loader": "^0.7.1",
        "instantclick": "^3.1.0-2",
        "instantclick2": "^1.1.0",
        "jquery": "^3.3.1",
        "peaks.js": "^0.9.7",
        "ritmo": "^0.5.0",
        "social-likes-next": "^1.1.0",
        "vue": "^2.5.13",
        "webpack-uglify-js-plugin": "^1.1.9",
        "youtube-iframe": "^1.0.3"
      }
    }




我之前已经使用过这个脚本并且运行良好。如果你能帮助我,那对我来说将是一个很大的安慰。

感谢您的帮助

2 个答案:

答案 0 :(得分:1)

仅当您安装了webpack 4.*时才会发生这种情况,那里有webpack 3

尝试升级到webpack 4。由于webpackwebpack-cli被拆分为不同的包,因此可以使用。

答案 1 :(得分:0)

日志回答你的问题: - >使用npm时:npm install webpack-cli -D - >使用纱线时:纱线添加webpack-cli -D

使用npm或yarn安装它。

显然有一个包已经分开了两个。