npm 和yarn的安装和使用方法

npm 和yarn的安装和使用方法

一、npm安装

bash 复制代码
gnvm install 10.24.1
gnvm use 10.24.1
gnvm ls
gnvm npm global

#npm i 报错问题error Unexpected token '.'

#解决办法 node降级安装为node 14.21.3版本 npm 6.14.18版本

#gnvm search 14..

bash 复制代码
gnvm install 14.21.3
gnvm ls
gnvm use 14.21.3
gnvm npm global

#npm install 报错问题error cb() never called!

#解决办法:node降级为node 10.24.1 npm 6.14.12

#gnvm search 10..

bash 复制代码
gnvm install 10.24.1
gnvm use 10.24.1
gnvm ls
gnvm npm global

二、yarn 安装

#Yarn是由Facebook、Google、Exponent 和 Tilde 联合推出了一个新的 JS 包管理工具 ,

#正如官方文档中写的,Yarn 是为了弥补 npm 的一些缺陷而出现的。

#关于频繁变动 node 版本,建议使用 gnvm/nvm 管理,就像 python 用 conda

bash 复制代码
npm install -g yarn
yarn -v

三、设置数据源

bash 复制代码
#set source taotao
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 config get registry

npm config set registry https://registry.npm.taobao.org
npm config get registry

#set source npm mirror
npm config set registry https://registry.npmmirror.com
npm config get registry

yarn config set registry https://registry.npmmirror.com -g
yarn config get registry

四、yarn和npm命令对照

bash 复制代码
npm                            yarn
npm install                    yarn
npm install react --save       yarn add react
npm uninstall react --save     yarn remove react
npm install react --save-dev   yarn add react --dev
npm update --save              yarn upgrade

五、yarn下载依赖包

bash 复制代码
yarn
yarn -v

六、npm下载依赖包

bash 复制代码
npm install
npm -v

本blog地址:https://blog.csdn.net/hsg77

相关推荐
w32963627116 小时前
飞书接单到月度结算:我用一个 DSH 插件跑通鞋类采购 WMS,附 22 项验收
pdf·node.js·飞书·后端开发·ai agent
濮水大叔1 天前
Cabloy/Vona 为什么不需要 NestJS 的 Dynamic Module
typescript·node.js·nestjs
匠云创新1 天前
读完一万段要两分钟:我们把标书读取从 WPS 对象模型搬到了 docx 解析
性能优化·node.js
某哈压力大2 天前
SSH 突然 Connection reset?不是密钥坏了,是 OpenSSL 把 sshd 干趴了
前端·node.js·命令行
回眸&啤酒鸭2 天前
【回眸】Node.js 新手从零到一实战指南
node.js
浪遏2 天前
recruitment-cli:让 AI 接手求职招聘,从架构到一次发送超时
架构·typescript·node.js
沉默小管3 天前
我用 NestJS + Nuxt 3 做了个导航站,聊几个踩过的坑
node.js·seo
dreams_dream3 天前
微信小程序-使用npm包
微信小程序·小程序·npm
非优秀程序员4 天前
第02章 杭电的英语老师与一台服务器|《互联网产品恩仇录》
数据库·node.js·代码规范
周杰伦的稻香4 天前
Hexo 腾讯视频追剧页插件:hexo-tengxun-eucalyptus 安装使用
npm