自学vue-loader+webpack时碰到的问题

这是代码部分:

module.exports ={
    entry: './main.js',
    //出口文件
    output: {
        path: __dirname,
        filename:'build.js'
    },
    module:{
        loaders:[
            {test:/\.vue$/,loader:'vue'},
            {test:/\.js$/,loader:'babel',exclude:/node_modules/}
        ],
        babel:{
            presets:['es2015'],
            plugins:['transform-runtime']
        }

    }
}

报错如下:
webpack-dev-server --inline --hot --port 8082
Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.

  • configuration.module has an unknown property 'babel'. These properties are va lid:
    object { exprContextCritical?, exprContextRecursive?, exprContextRegExp?, exp rContextRequest?, loaders?, noParse?, rules?, unknownContextCritical?, unknownCo ntextRecursive?, unknownContextRegExp?, unknownContextRequest?, unsafeCache?, wr appedContextCritical?, wrappedContextRecursive?, wrappedContextRegExp?, strictEx portPresence?, strictThisContextOnImports? }

Options affecting the normal modules (NormalModuleFactory).

npm ERR! Windows_NT 10.0.15063
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\ node_modules\npm\bin\npm-cli.js" "run" "dev"
npm ERR! node v6.9.1
npm ERR! npm v3.10.8
npm ERR! code ELIFECYCLE
npm ERR! vue-loader@1.0.0 dev: webpack-dev-server --inline --hot --port 8082
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the vue-loader@1.0.0 dev script 'webpack-dev-server --inline --hot --port 8082'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the vue-loader package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! webpack-dev-server --inline --hot --port 8082
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs vue-loader
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls vue-loader
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:

之前看有人说是因为我webpack是2的版本,这个配置是1的,然后我卸载了2之后又装了1然而还是报这样的错,不知道到底问题在哪QAQ

阅读 4k
2 个回答

webpack2

 {test:/\.vue$/,loader:'vue-loader'},
 {test:/\.js$/,loader:'babel-loader',exclude:/node_modules/}

不能省略 -loader

另外你可以到package.json看自己的webpack版本,可以直接上3

babel:{
            presets:['es2015'],
            plugins:['transform-runtime']
        }

这段你确定是写在webpack.config.js里的module?我记得好像是写在.babelrc这个文件的里,况且你这里还报babel错误,你可以调试一下

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题