环境配置


一、Nodejs环境配置

node官网:[https://nodejs.org/en/download/]

1、配置默认安装目录和缓存日志目录

在安装的文件夹【D:\environment\nodejs】下创建两个文件夹【node_global】及【node_cache】
nodejs环境配置 - 图1
打开cmd配置

  1. npm config set prefix "D:\environment\nodejs\node_global"
  2. npm config set cache "D:\environment\nodejs\node_cache"

2、配置环境变量

修改用户变量
D:\environment\nodejs\node_global
nodejs环境配置 - 图2

新建系统变量
NODE_PATH
D:\environment\nodejs\node_modules
nodejs环境配置 - 图3

添加系统变量Path
D:\environment\nodejs
nodejs环境配置 - 图4
D:\environment\nodejs\node_global
image.png

3、检查配置

用管理员身份打开

npm install express -g
nodejs环境配置 - 图6

4、安装vue

  1. npm install vue@next #最新稳定版
  2. npm install -g @vue/cli #vue脚手架

5、安装nrm

  1. npm install -g nrm
  2. nrm --version
  3. nrm ls
  4. nrm use #使用源
  5. nrm add <registry> <url> #添加源
  6. nrm del <registry> #删除源

修改cli.js文件的211行代码为||
image.png

  1. if (hasOwnProperty(customRegistries, name) || (name in registries || customRegistries[name].registry === registry.registry)) {
  2. registry[FIELD_IS_CURRENT] = true;
  3. customRegistries[name] = registry;
  4. }
  5. setCustomRegistry(customRegistries);
  6. printMsg(['', ' Registry has been set to: ' + newR, '']);

如果没用那么执行下面的代码

  1. npm install Pana/nrm -g

6、安装typescript

  1. npm i -g typescript
  2. npm i -g ts-node