因爲 vue2.0 致使其餘相關編譯打包工具沒更新致使
解決辦法: 請運行如下命令vue
1
|
npm update -g
|
報錯node
1
2
3
4
5
6
7
8
|
Error: Cannot find module
'opn'
Error: Cannot find module
'webpack-dev-middleware'
Error: Cannot find module
'express'
Error: Cannot find module
'compression'
Error: Cannot find module
'sockjs'
Error: Cannot find module
'spdy'
Error: Cannot find module
'http-proxy-middleware'
Error: Cannot find module
'serve-index'
|
若是你用的是老版本的 vue-cli 還可能報其餘錯誤,須要更新一下 vue-cliwebpack
1
|
npm update vue-cli
|
安裝一下這個依賴到工程開發環境web
1
2
3
4
5
6
7
8
9
|
cnpm install opn --save-dev
cnpm install webpack-dev-middleware --save-dev
cnpm install express --save-dev
cnpm install compression --save-dev
cnpm install sockjs --save-dev
cnpm install spdy --save-dev
cnpm install http-proxy-middleware --save-dev
cnpm install serve-index --save-dev
cnpm install connect-history-api-fallback --save-dev
|
再啓動項目,報錯vue-cli
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
ERROR
in
./src/main.js
Module build failed: Error: Cannot find module
'babel-runtime/helpers/typeof'
at Function.Module._resolveFilename (module.js:440:15)
at Function.Module._load (module.js:388:25)
at Module.require (module.js:468:17)
at require (
internal
/module.js:20:19)
at Object.<anonymous> (/Volumes/MacStorage/Coding/Web/vue-test/node_modules/.6.17.0@babel-core/lib/transformation/file/index.js:6:16)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
@ multi main
ERROR
in
./~/.2.1.0-beta.8@webpack-dev-server/client/socket.js
Module not found: Error: Can
't resolve '
sockjs-client
' in '
/Volumes/MacStorage/Coding/Web/vue-test/node_modules/.2.1.0-beta.8@webpack-dev-server/client'
@ ./~/.2.1.0-beta.8@webpack-dev-server/client/socket.js 1:13-37
@ ./~/.2.1.0-beta.8@webpack-dev-server/client?http:
//localhost:8080
@ multi main
|
安裝一下 babel-runtimeexpress
1
|
cnpm install babel-helpers --save-dev
|
啓動項目,再次報錯npm
1
2
3
4
5
6
|
Module build failed: Error: Cannot find module
'babel-helpers'
Module build failed: Error: Cannot find module
'babel-traverse'
Module build failed: Error: Cannot find module
'json5'
Module build failed: Error: Cannot find module
'babel-generator'
Module build failed: Error: Cannot find module
'detect-indent'
Module build failed: Error: Cannot find module
'jsesc'
|
找不到依賴那就再安裝一下json
1
2
3
|
cnpm install babel-helpers --save-dev
cnpm install babel-traverse --save-dev
cnpm install json5 --save-dev
|
遇到api
1
|
Module build failed: Error: Cannot find module
'模塊名'
|
那就安裝
1
2
3
|
cnpm install 模塊名 --save-dev(關於環境的,表現爲npm run dev 啓動不了)
cnpm install 模塊名 --save(關於項目的,好比main.js,表現爲npm run dev 成功以後控制檯報錯)
好比escape-
string
-regexp、strip-ansi、has-ansi、
is
-finite、emojis-list
|
寫示例時注意:
1、一個組件下只能有一個並列的 div,能夠這麼寫,因此複製官網示例的時候只要複製 div 裏面的內容就好。
2、數據要寫在 return 裏面而不是像文檔那樣子寫