使用npm run build时,出现下面的问题

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

慕粉1030219053

2018-09-18 15:48

使用npm run build时,出现下面的问题。检查代码,应该是没有写错的。怎么解决呢?

npm ERR! code ELIFECYCLE

npm ERR! errno 1

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

npm ERR! Exit status 1

npm ERR!

npm ERR! Failed at the vue_ssr_tech@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!     /Users/mymac/.npm/_logs/2018-09-18T07_41_36_761Z-debug.log

我按照教学视频配置的代码如下:

https://img2.mukewang.com/5ba0ad8a0001fa4311580618.jpg

https://img2.mukewang.com/5ba0ad8c00016a9e13460956.jpg

https://img.mukewang.com/5ba0ad8d0001ce9009300966.jpg

https://img.mukewang.com/5ba0ad930001a1cb11740552.jpg


写回答 关注

3回答

  • LGforgone
    2018-09-24 01:33:14
    const path = require('path')
    const { VueLoaderPlugin } = require('vue-loader')
    
    module.exports = {
        entry: path.join(__dirname,'src/index.js'),
        output: {
            filename: "bundle.js",
            path: path.join(__dirname,'dist')
        },
        module: {
            rules: [
                {
                    test: /\.vue$/,
                    loader: 'vue-loader'
                },
                {
                    test: /\.css$/,
                    use: ['style-loader', 'css-loader']
                },
                {
                    test: /\.(gif|jpg|jpeg|png|svg)$/,
                    use: [
                        {
                            loader: 'url-loader',
                            options: {
                                limit: 1024,
                                name: '[name].[ext]'
                            }
                        }
                    ]
                }
            ]
        },
        plugins: [
            new VueLoaderPlugin()
        ]
    }


    点又

    有用,赞一个

    2018-10-05 20:28:03

    共 1 条回复 >

  • LGforgone
    2018-09-24 01:27:56

    这个可能是你有在webpack.config.js中加入plugins(我多装了style-loader url-loader file-loader)

    const path = require('path')
    
    
    module.exports = {
        entry: path.join(__dirname,'src/index.js'),
        output: {
            filename: "bundle.js",
            path: path.join(__dirname,'dist')
        },
        module: {
            rules: [
                {
                    test: /\.vue$/,
                    loader: 'vue-loader'
                },
                {
                    test: /\.css$/,
                    use: ['style-loader', 'css-loader']
                },
                {
                    test: /\.(gif|jpg|jpeg|png|svg)$/,
                    use: [
                        {
                            loader: 'url-loader',
                            options: {
                                limit: 1024,
                                name: '[name].[ext]'
                            }
                        }
                    ]
                }
            ]
        },
        
    }


    LGforg...

    之前打错了,是可能你没有加plugins,编译的时候报错好像有提醒的,我之前好像遇到过,加了plugins就好了

    2018-09-24 01:30:19

    共 1 条回复 >

  • littlemin
    2018-09-18 22:25:41

    这个是新版本的webpack有更改过的缘故,只要把<style></style>中间的样式注释掉就不会报错,应该是少了一个关于style的插件,但具体是什么我暂时也不知道

Vue+Webpack打造todo应用

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

84606 学习 · 787 问题

查看课程

相似问题