今天開始學vue,環境建到一半就卡住了,出現這個
C:\Users\data\Desktop\專案>npm run dev
> vue_practice@1.0.0 dev C:\Users\data\Desktop\專案
> cross-env NODE_ENV=development webpack-dev-server --open --hot
internal/modules/cjs/loader.js:960
throw err;
^
Error: Cannot find module 'webpack-cli/bin/config-yargs'
Require stack:
- C:\Users\data\Desktop\專案\node_modules\webpack-dev-server\bin\webpack-dev-server.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:957:15)
at Function.Module._load (internal/modules/cjs/loader.js:840:27)
at Module.require (internal/modules/cjs/loader.js:1019:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object.<anonymous> (C:\Users\data\Desktop\專案\node_modules\webpack-dev-server\bin\webpack-dev-server.js:65:1)
at Module._compile (internal/modules/cjs/loader.js:1133:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
at Module.load (internal/modules/cjs/loader.js:977:32)
at Function.Module._load (internal/modules/cjs/loader.js:877:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\data\\Desktop\\專案\\node_modules\\webpack-dev-server\\bin\\webpack-dev-server.js'
]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! vue_practice@1.0.0 dev: `cross-env NODE_ENV=development webpack-dev-server --open --hot`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the vue_practice@1.0.0 dev 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\data\AppData\Roaming\npm-cache\_logs\2020-11-22T10_01_22_287Z-debug.log
可是webpack-cli我後來自己npm install進去了,依舊沒辦法執行,想請問有解決方法嗎?
你會出現這個錯誤很有可能是因為你用的是 webpack 5 ,如果是請你安裝 webpack-cli
與 webpack-dev-server
並換成用以下指令執行:
$ webpack serve
一開始學vue,怎會從vue-cli下手?
應該是先從vue.js開始學吧