<meta charset="utf-8">
<article class="_2rhmJa">
創(chuàng)建一個 vue 項目步驟如下:
先進入一個事先準備好的目錄,比如demo
目錄凡恍,然后在目錄中做初始化操作:
$ vue init webpack project名
注意:project名 不能包含大寫字母
webpack 參數(shù)是指這個項目將會在開發(fā)和完成階段自動打包代碼
初始化可能會失敗缘缚,錯誤信息如下:
vue-cli · Failed to download repo vuejs-templates/webpack: tunneling socket could not be established,
解決方案
1. 設置所有代理為 null(無效)
npm config set http-proxy null
npm config set https-proxy null
2. 使用本地的 webpack(有效)
從 github 上下載 webpack 庫到本地, github 地址:https://github.com/vuejs-templates/webpack
岛马,然后 vue init /home/tony/software/webpack vue_test
(base) tony@tony-Swift-SF314-54:~/Project/WebProject/uni-appProject$ vue init /home/tony/software/webpack vueTest
? Project name vue_test
? Project description A Vue.js project
? Author tony
? Vue build standalone
? Install vue-router? Yes
? Use ESLint to lint your code? Yes
? Pick an ESLint preset Standard
? Set up unit tests Yes
? Pick a test runner jest
? Setup e2e tests with Nightwatch? Yes
? Should we run `npm install` for you after the project has been created? (recom
mended) npm
vue-cli · Generated "vueTest".
# Installing project dependencies ...
# ========================
如果 Should we run npm install
那按了回車陨收,則項目創(chuàng)建好后會使用 npm 安裝依賴(可能卡住不動)势告,此時可以直接 Ctrl+C
退出程序岸啡,進入項目根目錄打開命令行使用 cnpm install
安裝