npm run build 報錯 請問是哪里的問題
> [email protected] build E:\workspace\整理文件web\綜合練習\vue\vue核心技術\VUE-SSR-TECH
> webpack --config webpack.config.js
Hash: 96a4b1c95b2729429677
Version: webpack 4.35.3
Time: 480ms
Built at: 2019-07-12 16:36:36
?1 asset
Entrypoint main = bundle.js
[0] (webpack)/buildin/global.js 472 bytes {0} [built]
[2] ./src/index.js 186 bytes {0} [built]
[3] ./src/app.vue 426 bytes {0} [built] [failed] [3 errors]
??? + 4 hidden modules
WARNING in configuration
The 'mode' option has not been set, webpack will fallback to 'production' for this value. Set 'mode' option to 'development' or 'production' to enable defaults for each environment.
You can also set it to 'none' to disable any default behavior. Learn more: https://webpack.js.org/configuration/mode/
ERROR in ./src/app.vue
Module Error (from ./node_modules/vue-loader/lib/index.js):
[vue-loader] vue-template-compiler must be installed as a peer dependency, or a compatible compiler implementation must be passed via options.
?@ ./src/index.js 2:0-27
ERROR in ./src/app.vue
Module Error (from ./node_modules/vue-loader/lib/index.js):
vue-loader was used without the corresponding plugin. Make sure to include VueLoaderPlugin in your webpack config.
?@ ./src/index.js 2:0-27
ERROR in ./src/app.vue
Module build failed (from ./node_modules/vue-loader/lib/index.js):
TypeError: Cannot read property 'parseComponent' of undefined
??? at parse (E:\workspace\整理文件web\綜合練習\vue\vue核心技術\VUE-SSR-TECH\node_modules\@vue\component-compiler-utils\dist\parse.js:14:23)
??? at Object.module.exports (E:\workspace\整理文件web\綜合練習\vue\vue核心技術\VUE-SSR-TECH\node_modules\vue-loader\lib\index.js:67:22)
?@ ./src/index.js 2:0-27
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] build: `webpack --config webpack.config.js`
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\2019-07-12T08_36_36_666Z-debug.log
PS E:\workspace\整理文件web\綜合練習\vue\vue核心技術\VUE-SSR-TECH> npm run build
> [email protected] build E:\workspace\整理文件web\綜合練習\vue\vue核心技術\VUE-SSR-TECH
> webpack --config webpack.config.js
Hash: 96a4b1c95b2729429677
Version: webpack 4.35.3
Time: 508ms
Built at: 2019-07-12 16:38:41
?1 asset
Entrypoint main = bundle.js
[0] (webpack)/buildin/global.js 472 bytes {0} [built]
[2] ./src/index.js 186 bytes {0} [built]
[3] ./src/app.vue 426 bytes {0} [built] [failed] [3 errors]
??? + 4 hidden modules
WARNING in configuration
The 'mode' option has not been set, webpack will fallback to 'production' for this value. Set 'mode' option to 'development' or 'production' to enable defaults for each environment.
You can also set it to 'none' to disable any default behavior. Learn more: https://webpack.js.org/configuration/mode/
ERROR in ./src/app.vue
Module Error (from ./node_modules/vue-loader/lib/index.js):
[vue-loader] vue-template-compiler must be installed as a peer dependency, or a compatible compiler implementation must be passed via options.
?@ ./src/index.js 2:0-27
ERROR in ./src/app.vue
Module Error (from ./node_modules/vue-loader/lib/index.js):
vue-loader was used without the corresponding plugin. Make sure to include VueLoaderPlugin in your webpack config.
?@ ./src/index.js 2:0-27
ERROR in ./src/app.vue
Module build failed (from ./node_modules/vue-loader/lib/index.js):
TypeError: Cannot read property 'parseComponent' of undefined
??? at parse (E:\workspace\整理文件web\綜合練習\vue\vue核心技術\VUE-SSR-TECH\node_modules\@vue\component-compiler-utils\dist\parse.js:14:23)
??? at Object.module.exports (E:\workspace\整理文件web\綜合練習\vue\vue核心技術\VUE-SSR-TECH\node_modules\vue-loader\lib\index.js:67:22)
?@ ./src/index.js 2:0-27
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] build: `webpack --config webpack.config.js`
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\2019-07-12T08_38_41_819Z-debug.log
----------------------------------------------------------------------------------------------------------------------------
webpack.json.js文件:
const path = require('path')
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'
? ? ? ? ? ?}
? ? ? ?]
? ?}
}
-------------------------------------------------------------------------------------------------
package.json文件:
{
?"name": "vue-ssr-tech",
?"version": "1.0.0",
?"main": "index.js",
?"scripts": {
? ?"dev": "webpack --mode development",
? ?"test": "echo \"Error: no test specified\" && exit 1",
? ?"build": "webpack --config webpack.config.js"
?},
?"author": "",
?"license": "ISC",
?"dependencies": {
? ?"css-loader": "^3.0.0",
? ?"vue": "^2.6.10",
? ?"vue-loader": "^15.7.0",
? ?"webpack": "^4.35.3"
?},
?"devDependencies": {
? ?"webpack-cli": "^3.3.5"
?},
?"description": ""
}
2019-07-26
錯誤提示你的包依賴沒有裝好
你可以參考一下我的代碼https://github.com/carrieguo/vue.js-learn
2019-07-12
ERROR in ./src/app.vue
Module Error (from ./node_modules/vue-loader/lib/index.js):
[vue-loader] vue-template-compiler must be installed as a peer dependency, or a compatible compiler implementation must be passed via options.
沒有安裝?vue-template-compiler 模塊, 在vs-code里打開終端,確保是在當前項目,執行 npm run?vue-template-compiler.(一定要在當前項目打開終端, 之前老用cmd打開安裝,老是找不到模塊)