ERROR in ./page/app.vue
Module build failed (from ./node_modules/css-loader/index.js):
Unknown word (2:19)
1 | <template>
> 2 | <div id="test">{{text}}</div>
| ^
3 | </template>
4 | <script>
5 | export default {
@ ./page/index.js 2:0-27 8:18-21
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! wpc@1.0.0 build: `webpack --config webpack.config.js`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the wpc@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! C:\Users\Zuoqi Li\AppData\Roaming\npm-cache\_logs\2018-08-02T08_55_40_024Z-debug.log
C:\project\works_pro\wpc>npm i style-loader url-loader file-loader
npm WARN wpc@1.0.0 No description
npm WARN wpc@1.0.0 No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
我找到了答案,分享给大家。
只要修改webpack.config.js就可以打包了。
const path = require('path');
const {VueLoaderPlugin}=require('vue-loader');
module.exports = {
entry: path.resolve(__dirname, "src/index.js"), //webpack4官方绝对路径
devServer: {
contentBase: './dist'
},
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist')
},
module: {
rules: [
{
test: /\.vue$/,
use: [
'vue-loader'
]
},
{
test: /\.css$/,
use: [
'vue-style-loader', //可以不要
'style-loader',
'css-loader'
]
},
]
},
plugins:[
new VueLoaderPlugin()
]
};
Failed at the wpc@1.0.0 build script. 这个错误貌似是新版本的得在webpack.config.js加上
const VueLoaderPlugin = require('vue-loader/lib/plugin')
然后在 plugins 里面加 new VueLoaderPlugin()
不知道你的是不是因为这个,我的已经能跑了,都用的自动下载的版本。(今天刚开始学vue)