npm 常见包指令

204 阅读1分钟

包指令

快速创建package.json

npm init

安装一个包

npm i xxx 或者 npm install xxx

安装多个包

npm i xxx1 xxx2 或者 npm install xxx1 xxx2

卸载包

npm uninstall xxx

安装指定的包,并记录到 devDependencies 节点中

npm i 包名 -D, 完整写法 npm install 包名 --save-dev

切换 npm 的下包镜像源

# 查看当前的下包镜像源
npm config get registry
# 将下包的镜像源切换为淘宝镜像源
npm config set registry=https://registry.npm.taobao.org/
# 检查镜像源是否下载成功
npm config get registry

使用 nrm 切换下载包的服务器

# 通过 npm 包管理器,将 nrm 安装为全局可用的工具
npm i nrm -g
# 查看所有可用的镜像源
nrm ls
# 将下包的镜像源切换为taobao 镜像
nrm use taobao

i5ting_toc 实现md转html 的功能

i5ting_toc -f 要转化的md文件路径 -o

注册 npm 账号

  1. 访问 npm 网站,点击 sign up 按钮,进入注册用户界面
  2. 填写账号相关的信息:Full NamePublic EmailUsernamePassword
  3. 点击 Create an Account 按钮,注册账号
  4. 登录邮箱,点击验证链接,进行账号的验证

登录 npm 账号

npm login

把包发布到 npm

npm publish

删除已发布的包

npm unpublish 包名 --force