运行 npm run build时报错

来源:2-1 vue-loader+webpack项目配置

三体XRaindrop

2018-06-01 15:56

> todolist@1.0.0 build E:\work\todoList

> webpack --config webpack.config.js


One CLI for webpack must be installed. These are recommended choices, delivered as separate packages:

 - webpack-cli (https://github.com/webpack/webpack-cli)

   The original webpack full-featured CLI.

 - webpack-command (https://github.com/webpack-contrib/webpack-command)

   A lightweight, opinionated webpack CLI.

We will use "npm" to install the CLI via "npm install -D".

Which one do you like to install (webpack-cli/webpack-command):


One CLI needs to be installed alongside webpack to use the CLI.

npm ERR! code ELIFECYCLE

npm ERR! errno 1

npm ERR! todolist@1.0.0 build: `webpack --config webpack.config.js`

npm ERR! Exit status 1

npm ERR!

npm ERR! Failed at the todolist@1.0.0 build 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\Tom\AppData\Roaming\npm-cache\_logs\2018-06-01T07_54_45_313Z-debug.log


写回答 关注

8回答

  • 希文特_
    2018-06-01 16:32:43
    已采纳

    Which one do you like to install (webpack-cli/webpack-command):

    提示输入时,输出webpack-cli即可

  • 幕布斯0498935
    2019-09-23 12:10:38

    楼主,解决了吗,可以分享下嘛

  • 幕布斯0498935
    2019-09-23 12:09:49

    解决了吗

  • 慕粉130347768
    2019-03-01 15:27:20

    以上两个方法都试过了,没用

    最不强程序员

    我也是

    2019-05-22 21:03:15

    共 1 条回复 >

  • 晨风不可依米
    2019-01-07 01:12:58

    在webpack.config.js文件添加

    const VueLoaderPlugin = require('vue-loader/lib/plugin')

    module.exports = {

        //里面添加:

        plugins: [

            new VueLoaderPlugin()

        ]

    }

    这样就不会报错了

    晨风不可依米

    当然你也必须安装 webpack-cli

    2019-01-07 01:13:37

    共 1 条回复 >

  • 朱哥哥的媳妇
    2018-11-23 22:59:39

    那个都没有起效


  • qq_奋斗吧小青年_13
    2018-06-28 17:16:49

    webpack-cli和webpack-commond 选一个

  • 慕容5120236
    2018-06-05 23:10:32

    输入npm install webpack-cli -g或者npm install webpack-commond -g即可,必须加-g ,也就是全局安装,否则不行


Vue+Webpack打造todo应用

用前端最热门框架Vue+最火打包工具Webpack打造todo应用

84606 学习 · 787 问题

查看课程

相似问题