1 下载node.js包

https://npm.taobao.org/mirrors/node/v10.16.0/node-v10.16.0-win-x64.zip

2 解压

E:\develop\node-v10.16.0

3 创建两个依赖文件夹

E:\devdata\node\node_cache
E:\devdata\node\node_global

4 设置依赖下载路径

E:\develop\node-v10.16.0>npm config set cache "E:\devdata\node\node_cache"
E:\develop\node-v10.16.0>npm config set prefix "E:\devdata\node\node_global"

5 设置环境变量

NODE_HOME : E:\develop\node-v10.16.0
PATH添加 %NODE_HOME%;%NODE_HOME%\node-global

6 查看依赖下载路径

C:\Users\michael>npm config get cache
E:\devdata\node\node_cache

C:\Users\michael>npm config get prefix
E:\devdata\node\node_global

7 查看node版本

C:\Users\michael>node -v
v10.16.0

8 查看npm版本

C:\Users\michael>npm -v
6.9.0

9 修改npm镜像地址为淘宝镜像

官方网站: http://www.npmmirror.com/

C:\Users\michael>npm install -g cnpm --registry=https://registry.npmmirror.com
E:\develop\node-v10.16.0\node-global\cnpm -> E:\develop\node-v10.16.0\node-global\node_modules\cnpm\bin\cnpm
+ cnpm@6.1.0
updated 119 packages in 56.884s

10 yarn安装

npm install -g yarn(最好不要用别的安装命令,会没效果)
yarn --version
yarn config set registry https://registry.npm.taobao.org -g
yarn config set sass_binary_site http://cdn.npm.taobao.org/dist/node-sass -g

如果yarn命令找不到需要添加环境变量:
系统变量path添加 C:\Users\michael\node_modules\yarn\bin


一、Yarn 设置淘宝镜像
1.查询当前配置的镜像
yarn config get registry  // 默认:https://registry.yarnpkg.com
2.设置成淘宝镜像
yarn config set registry http://registry.npm.taobao.org/
3.设置成原始镜像
yarn config set registry http://registry.npmjs.org/


卸载: npm uninstall yarn -g

11 安装vue-cli脚手架

C:\Users\michael>cnpm install --global vue-cli
Downloading vue-cli to E:\develop\node-v10.16.0\node-global\node_modules\vue-cli_tmp
Copying E:\develop\node-v10.16.0\node-global\node_modules\vue-cli_tmp\_vue-cli@2.9.6@vue-cli to E:\develop\node-v10.16.0\node-global\node_modules\vue-cli
Installing vue-cli's dependencies to E:\develop\node-v10.16.0\node-global\node_modules\vue-cli/node_modules
[1/20] commander@^2.9.0 installed at node_modules\_commander@2.20.0@commander
[2/20] consolidate@^0.14.0 installed at node_modules\_consolidate@0.14.5@consolidate
[3/20] minimatch@^3.0.0 installed at node_modules\_minimatch@3.0.4@minimatch
[4/20] multimatch@^2.1.0 installed at node_modules\_multimatch@2.1.0@multimatch
[5/20] rimraf@^2.5.0 existed at node_modules\_rimraf@2.6.3@rimraf
[6/20] ora@^1.3.0 installed at node_modules\_ora@1.4.0@ora
[7/20] semver@^5.1.0 installed at node_modules\_semver@5.7.0@semver
[8/20] chalk@^2.1.0 installed at node_modules\_chalk@2.4.2@chalk
[9/20] read-metadata@^1.0.0 installed at node_modules\_read-metadata@1.0.0@read-metadata
[10/20] handlebars@^4.0.5 installed at node_modules\_handlebars@4.1.2@handlebars
[11/20] async@^2.4.0 installed at node_modules\_async@2.6.2@async
[12/20] uid@0.0.2 installed at node_modules\_uid@0.0.2@uid
[13/20] tildify@^1.2.0 installed at node_modules\_tildify@1.2.0@tildify
[14/20] user-home@^2.0.0 installed at node_modules\_user-home@2.0.0@user-home
[15/20] validate-npm-package-name@^3.0.0 installed at node_modules\_validate-npm-package-name@3.0.0@validate-npm-package-name
[16/20] coffee-script@1.12.7 installed at node_modules\_coffee-script@1.12.7@coffee-script
[17/20] download-git-repo@^1.0.1 installed at node_modules\_download-git-repo@1.1.0@download-git-repo
[18/20] metalsmith@^2.1.0 installed at node_modules\_metalsmith@2.3.0@metalsmith
[19/20] request@^2.67.0 installed at node_modules\_request@2.88.0@request
[20/20] inquirer@^6.0.0 installed at node_modules\_inquirer@6.3.1@inquirer
deprecate coffee-script@1.12.7 CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
Recently updated (since 2019-06-05): 1 packages (detail see file E:\develop\node-v10.16.0\node-global\node_modules\vue-cli\node_modules\.recently_updates.txt)
  2019-06-11
    → inquirer@6.3.1 › rxjs@6.5.2 › tslib@^1.9.0(1.10.0) (06:29:46)
All packages installed (238 packages installed from npm registry, used 7s(network 7s), speed 725.06kB/s, json 223(412.66kB), tarball 4.71MB)
[vue-cli@2.9.6] link E:\develop\node-v10.16.0\node-global\vue@ -> E:\develop\node-v10.16.0\node-global\node_modules\vue-cli\bin\vue
[vue-cli@2.9.6] link E:\develop\node-v10.16.0\node-global\vue-init@ -> E:\develop\node-v10.16.0\node-global\node_modules\vue-cli\bin\vue-init
[vue-cli@2.9.6] link E:\develop\node-v10.16.0\node-global\vue-list@ -> E:\develop\node-v10.16.0\node-global\node_modules\vue-cli\bin\vue-list

12 创建名字为myweb项目

E:\developSpace\vueSpace>vue init webpack myweb

13 运行项目

E:\developSpace\vueSpace>cd myweb
E:\developSpace\vueSpace\myweb>cnpm i
E:\developSpace\vueSpace\myweb>cnpm run dev

14 打包项目

E:\developSpace\vueSpace\myweb>cnpm run build

15 谷歌浏览器跨域配置

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-web-security --user-data-dir=D:\devSpace\MyChromeDevUserData

16 error commander@9.2.0: The engine “node” is incompatible with this module

解决方案(2个)
方案1:卸载node重装指定版本范围的
Node.js 中文网 (nodejs.cn)

方案2:忽略错误后重新yarn install

yarn config set ignore-engines true
Logo

前往低代码交流专区

更多推荐