问答详情
源自:2-2 webpack配置项目加载各种静态资源及css预处理器

build 报错

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$/,

loader: 'css-loader'

}

]

},

plugins: [

vue VueLoaderPlugin()

]

}

上面是代码,下面是报错

SyntaxError: Unexpected identifier

    at new Script (vm.js:80:7)

    at NativeCompileCache._moduleCompile (D:\网页\todo\node_modules\v8-compile-cache\v8-compile-cache.js:240:18)

    at Module._compile (D:\网页\todo\node_modules\v8-compile-cache\v8-compile-cache.js:186:36)

    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)

    at Module.load (internal/modules/cjs/loader.js:600:32)

    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)

    at Function.Module._load (internal/modules/cjs/loader.js:531:3)

    at Module.require (internal/modules/cjs/loader.js:637:17)

    at require (D:\网页\todo\node_modules\v8-compile-cache\v8-compile-cache.js:161:20)

    at WEBPACK_OPTIONS (D:\网页\todo\node_modules\webpack-cli\bin\utils\convert-argv.js:115:13)

    at requireConfig (D:\网页\todo\node_modules\webpack-cli\bin\utils\convert-argv.js:117:6)

    at D:\网页\todo\node_modules\webpack-cli\bin\utils\convert-argv.js:124:17

    at Array.forEach (<anonymous>)

    at module.exports (D:\网页\todo\node_modules\webpack-cli\bin\utils\convert-argv.js:122:15)

    at yargs.parse (D:\网页\todo\node_modules\webpack-cli\bin\cli.js:71:45)

    at Object.parse (D:\网页\todo\node_modules\yargs\yargs.js:567:18)

    at D:\网页\todo\node_modules\webpack-cli\bin\cli.js:49:8

    at Object.<anonymous> (D:\网页\todo\node_modules\webpack-cli\bin\cli.js:375:3)

    at Module._compile (internal/modules/cjs/loader.js:701:30)

    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)

    at Module.load (internal/modules/cjs/loader.js:600:32)

    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)

    at Function.Module._load (internal/modules/cjs/loader.js:531:3)

    at Module.require (internal/modules/cjs/loader.js:637:17)

    at require (internal/modules/cjs/helpers.js:22:18)

    at Object.<anonymous> (D:\网页\todo\node_modules\webpack\bin\webpack.js:156:2)

    at Module._compile (internal/modules/cjs/loader.js:701:30)

    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)

    at Module.load (internal/modules/cjs/loader.js:600:32)

    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)

npm ERR! code ELIFECYCLE

npm ERR! errno 1

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

npm ERR! Exit status 1

npm ERR!

npm ERR! Failed at the todo@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!     D:\nodejs\node_cache\_logs\2019-05-12T10_55_54_328Z-debug.log


提问者:慕沐4494624 2019-05-12 19:02

个回答

  • 妄越Web
    2019-06-20 17:54:53

    // webpack.config.js
    const VueLoaderPlugin = require('vue-loader/lib/plugin')
    看官方文档怎么写的吧https://vue-loader.vuejs.org/guide/#manual-setup

  • 慕运维435783
    2019-05-13 16:36:34

    plugins: [

    new VueLoaderPlugin()

    ]

    看是不是这里写错了