当前位置:网站首页>npm操作指令
npm操作指令
2022-07-26 05:01:00 【spy过家家】
# npm
npm是nodejs的包管理工具
npm可以支持:
1、将包从服务器下载到本地
2、将本地的包上传至服务器
3、将软件从服务器下载到本地
#### 初始化项目
使用 `npm init` 命令初始化一个项目,该命令会在项目根目录创建一个package.json文件。
#### 安装一个包
npm install xxx --save-dev:以开发模式安装一个xxx的包
npm install xxx --save: 以生产模式安装一个xxx的包
其中install可以简写成i --save可以简写成 -S --save-dev可以简写成-D
比如安装jquery:
npm i jquery -D
-S参数可以省略,默认以生产模式安装
#### 恢复所有依赖
npm install 或者 npm i
#### 卸载一个包
npm unistall xxx 卸载xxx这个包
#### 更新一个包
npm update xxx 更新包
#### 查看npm镜像源
npm config get registry
#### 安装nrm
nrm是一个镜像源管理工具
npm i nrm -g // 全局安装
#### 查看nrm镜像支持
nrm ls
#### 切换镜像
nrm use taobao
# yarn
yarn是npm的进阶版 但是yarn和npm不能共存 一个项目用npm就不能用yarn
#### 安装yarn
1、去官网找安装包手动安装
2、通过npm安装:
npm i yarn -g
#### 初始化项目
yarn init
#### 安装包
yarn add xxx 安装一个包
yarn add [email protected] 指定版本安装
yarn add xxx --dev 开发环境
yarn add xxx --peer 生产环境
#### 升级包
yarn upgrade xxx 更新一个包
#### 移除包
yarn remove xxx 移除/卸载一个包
#### 安装全部依赖
yarn install yarn
# cnpm
cnpm是淘宝克隆的npm,用淘宝的镜像复制了一份npm
#### 安装cnpm
npm i cnpm -g
对包管理的操作和npm一模一样
例如安装包用的是:
cnpm i jquery -S
如何把一个yarn管理的项目改成npm
1、删除yarn.lock
2、删除nodemodules目录
3、npm install 使用npm恢复项目
边栏推荐
- How to connect tdengine through idea database management tool?
- To study the trend of open source and gain insight into the future of the industry, stonedb community and the China Academy of communications and communications released the Research Report on the dev
- NFT的几种发行方式你都了解过吗?不同的发行方式有什么优缺点?
- 异步时父子线程间的ThreadLocal传递问题
- 阿里三面:MQ 消息丢失、重复、积压问题,如何解决?
- Redis过期删除策略和内存淘汰策略
- Unnamed Article 33
- 【洛谷】P3919 【模板】可持久化线段树1(可持久化数组)
- 数据库启动报:ORA-29702: error occurred in Cluster Group Service
- 2022 Hangdian multi school DOS card (line segment tree)
猜你喜欢

Principle of image nonlocal mean filtering

MySQL八股知识点:从入门到删库

Excel VBA:实现自动下拉填充公式至最后一行

User defined type details

Sliding window -- leetcode solution

阿里云工业视觉智能工程师ACP认证——备考

Customer service relationship management based on SQL net enterprise messenger enterprise communications

AXI协议(5):AXI协议的burst机制

汉字风格迁移篇---通过生成对抗网络学习一对多程式化汉字的转换和生成

Can serial port can 232 can 485 serial port to CANbus bus gateway module can232/485mb converter cancom
随机推荐
Principle of image nonlocal mean filtering
Fill in the vacancy, and fill in later
Rman-06031 cannot convert database keywords
批量将PPM格式图片转化为JPG格式
MySQL八股知识点:从入门到删库
STM32 development | ad7606 parallel multi-channel data acquisition
"Game engine light in light out" 4. shader
创建MySQL数据库的两种方式
Kubernetes 进阶训练营 调度器
The pit of history can only be filled up as far as possible
【洛谷】P3919 【模板】可持久化线段树1(可持久化数组)
What are the restrictions on opening futures accounts? Where is the safest place to open an account?
异步时父子线程间的ThreadLocal传递问题
Excel VBA:将多个工作表保存为新文件
User defined type details
Autocomplete prevents the form from automatically filling in
clock_ gettime
推荐系统-机器学习
Redis expiration deletion strategy and memory obsolescence strategy
Redis solves the problem of oversold inventory