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

有人知道这个是为什么吗?

ERROR in ./src/app.vue

Module build failed (from ./node_modules/vue-loader/index.js):

TypeError: Cannot read property 'vue' of undefined

    at Object.module.exports (D:\vuePro\vue-ssr-tech\node_modules\vue-loader\lib\loader.js:61:18)

 @ ./src/index.js 2:0-27 8:21-24


正在回答

2 回答

3q,还是插件的版本有问题。

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

关键的代码:webpack.config.js中

const path=require('path')

const isDev=process.env.NODE_ENV ==='development'
const HTMLPlugin=require('html-webpack-plugin')
const webpack=require('webpack')

const config = {
    target:'web',
    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:/\.styl/,
                use:[
                    'style-loader',
                    'css-loader',
                    'stylus-loader'
                ]
            },
            {
                test: /\.(gif|jpg|jpeg|png|svg)$/,
                use: [
                    {
                        loader:'url-loader',
                        options:{
                            limit:1024,
                            name:'[name]-a.[ext]'
                        }
                    }
                ]
            }
        ]
    },
    plugins: [
        new webpack.DefinePlugin({
            'process.env':{
                NODE_ENV:isDev?'"development"':'"production"'
            }
        }),
        
        new HTMLPlugin()
    ]
}

if(isDev){
    config.devtool="#cheap-module-eval-source-map"
    config.devServer={
        port:8000,
        host:'0.0.0.0',
        overlay:{
            errors:true
        },
        open:true,
        hot:true
    }
    config.plugins.push(
        new webpack.HotModuleReplacementPlugin(),
        new webpack.NoEmitOnErrorsPlugin()
    )
}

module.exports=config


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

qq__eGJOWX

const path=require('path') const VueLoaderPlugin = require('vue-loader/lib/plugin'); const isDev=process.env.NODE_ENV ==='development' const HTMLPlugin=require('html-webpack-plugin') const webpack=require('webpack')
2018-11-12 回复 有任何疑惑可以回复我~
#2

qq__eGJOWX

粘贴进去给我删了这关键的地方了,什么鬼 const VueLoaderPlugin = require('vue-loader/lib/plugin'); new VueLoaderPlugin(),
2018-11-12 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

有人知道这个是为什么吗?

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