为了账号安全,请及时绑定邮箱和手机立即绑定

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

使用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://img1.sycdn.imooc.com//5ba0ad8a0001fa4311580618.jpg

https://img1.sycdn.imooc.com//5ba0ad8c00016a9e13460956.jpg

https://img1.sycdn.imooc.com//5ba0ad8d0001ce9009300966.jpg

https://img1.sycdn.imooc.com//5ba0ad930001a1cb11740552.jpg


正在回答

3 回答

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()
    ]
}


1 回复 有任何疑惑可以回复我~
#1

点又

有用,赞一个
2018-10-05 回复 有任何疑惑可以回复我~

这个可能是你有在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]'
                        }
                    }
                ]
            }
        ]
    },
    
}


0 回复 有任何疑惑可以回复我~
#1

LGforgone

之前打错了,是可能你没有加plugins,编译的时候报错好像有提醒的,我之前好像遇到过,加了plugins就好了
2018-09-24 回复 有任何疑惑可以回复我~

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

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

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

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信