node.js起步 一

  1. 查看npm相关参数
npm config list
npm config ls -l 查看全部
  1. 设置全局的 插件保存地址 和下载插件时的 缓存地址
npm config set prefix "C:\node\node_global"
npm config set cache "C:\node\node_cache"
或者打开 %NODE_HOME%\npm\.npmrc文件,修改如下:
cache=D:\devTools\node-v14.16.1-win-x64\node_cache
prefix=D:\devTools\node-v14.16.1-win-x64\node_global
registry=https://registry.npm.taobao.org
  1. 修改registry地址,比如修改为淘宝镜像源。
npm set registry https://registry.npm.taobao.org/
 删除镜像源配置 
npm config rm registry
  1. cnpm 中国境内的npm镜像库插件
npm install -g --save cnpm 
  1. nrm 镜像源管理
npm install nrm -g --save
       用nrm ls命令查看默认配置,带*号即为当前使用的配置
nrm ls
  npm ---- https://registry.npmjs.org/
  cnpm --- http://r.cnpmjs.org/
* taobao - https://registry.npm.taobao.org/
  nj ----- https://registry.nodejitsu.com/
  rednpm - http://registry.mirror.cqupt.edu.cn/
  npmMirror  https://skimdb.npmjs.com/registry/
  edunpm - http://registry.enpmjs.org/
      也可以直接输入以下命令查看当前使用的是哪个源
nrm current
      切换源
nrm use cnpm
      用nrm add 命令添加私有npm源如http://registry.npm.xx.org(随便写的),起个别名叫xx
nrm add xxhttp://registry.npm.xx.org
     测试下速度
nrm test npm
  1. 更新Node版本和npm版本

     清除node的cache(清除node的缓存,这个看情况而定不是必须的)
    
npm cache clean -f 
更新node版本
npm install npm@latest -g 

这里的latest表示最新版本。

也可以使用具体的版本号,
npm install npm@6.10.0 -g

表示下载6.10.0这个版本的npm。

再查一遍本机当前Node和npm的版本吧
node -v 
npm -v
  1. 安装yarn
npm install yarn -g
查看安装路径
where yarn
查看yarn版本号
 yarn -v 

或者

yarn --version 
加快yarn启动速度,使用全局设置的命令:
yarn config set registry https://registry.npm.taobao.org --global
yarn config set disturl https://npm.taobao.org/dist --global
  1. yarn 的官网 地址

info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值