亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

運行npm run build報錯

ERROR in ./src/app.vue?vue&type=style&index=0&lang=css

Module parse failed: Unexpected character '#' (16:0)

You may need an appropriate loader to handle this file type.

|

|

| #test{

| ? ? color: red;

| }

?@ ./src/app.vue 4:0-62

?@ ./src/index.js


ERROR in ./src/app.vue?vue&type=template&id=bced26ea

Module parse failed: Unexpected token (2:0)

You may need an appropriate loader to handle this file type.

|

| <div id="test">{{test}}</div>

|

?@ ./src/app.vue 1:0-81 11:2-8 12:2-17

?@ ./src/index.js


ERROR in ./src/app.vue

vue-loader was used without the corresponding plugin. Make sure to include VueLoaderPlugin in your webpack config.

?@ ./src/index.js 2:0-28 8:19-22


ERROR in ./src/app.vue?vue&type=template&id=bced26ea

vue-loader was used without the corresponding plugin. Make sure to include VueLoaderPlugin in your webpack config.

?@ ./src/app.vue 1:0-81 11:2-8 12:2-17

?@ ./src/index.js


ERROR in ./src/app.vue?vue&type=script&lang=js

vue-loader was used without the corresponding plugin. Make sure to include VueLoaderPlugin in your webpack config.

?@ ./src/app.vue 2:0-54 3:0-49 3:0-49 10:2-8

?@ ./src/index.js


ERROR in ./src/app.vue?vue&type=style&index=0&lang=css

vue-loader was used without the corresponding plugin. Make sure to include VueLoaderPlugin in your webpack config.

?@ ./src/app.vue 4:0-62

?@ ./src/index.js

npm ERR! code ELIFECYCLE

npm ERR! errno 2

npm ERR! [email protected] build: `webpack --config webpack.config.js --mode production`

npm ERR! Exit status 2

npm ERR!

npm ERR! Failed at the [email protected] 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\Administrator\AppData\Roaming\npm-cache\_logs\2018-05-14T08_01_24_420Z-debug.log


D:\wxq\myPro\elm\webtest>


正在回答

2 回答

補充一下,我剛看了一下vue-loader的文檔

應該是vue-loader的版本從14.x開始就需要這樣做了,與webpack版本沒什么關系

```

//?webpack.config.jsconst?path?=?require('path')const?VueLoaderPlugin?=?require('vue-loader/lib/plugin')module.exports?=?{
??mode:?'development',
??module:?{
????rules:?[
??????{
????????test:?/\.vue$/,
????????loader:?'vue-loader'
??????},
??????//?this?will?apply?to?both?plain?`.js`?files
??????//?AND?`<script>`?blocks?in?`.vue`?files
??????{
????????test:?/\.js$/,
????????loader:?'babel-loader'
??????},
??????//?this?will?apply?to?both?plain?`.css`?files
??????//?AND?`<style>`?blocks?in?`.vue`?files
??????{
????????test:?/\.css$/,
????????use:?[
??????????'vue-style-loader',
??????????'css-loader'
????????]
??????}
????]
??},
??plugins:?[
????//?make?sure?to?include?the?plugin?for?the?magic
????new?VueLoaderPlugin()
??]}

```

文檔地址:https://vue-loader.vuejs.org/guide/


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

有這個錯誤,想來你的webpack版本應該是4.x,看時間應該是4.8的版本

解決辦法

在webpack的baseconfig里面

先引入vue-loader的plugin

const VueLoaderPlugin = require('vue-loader/lib/plugin')

然后在

plugins: [

????new VueLoaderPlugin()

]




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

舉報

0/150
提交
取消
Vue+Webpack打造todo應用
  • 參與學習       84621    人
  • 解答問題       812    個

用前端最熱門框架Vue+最火打包工具Webpack打造todo應用

進入課程

運行npm run build報錯

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號