老師能看一下為什么還會報(bào)錯(cuò)
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"})
2018-09-14
我找到了答案,分享給大家。
只要修改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()
]
};
2018-08-03
Failed at the wpc@1.0.0 build script. 這個(gè)錯(cuò)誤貌似是新版本的得在webpack.config.js加上
const VueLoaderPlugin = require('vue-loader/lib/plugin')
然后在 plugins 里面加 new VueLoaderPlugin()
不知道你的是不是因?yàn)檫@個(gè),我的已經(jīng)能跑了,都用的自動(dòng)下載的版本。(今天剛開始學(xué)vue)