Skip to main content

Node.Js 命令集

NPM​

不常用命令​

设置 repository​

A. 临时

npm --registry https://registry.npm.taobao.org {command}

B. config

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

#查看npm当前配置
npm config list

C. 配置文件

vim ~/.npmrc

registry = https://registry.npm.taobao.org

PNPM​

node-linker​

有些情况下,依赖可能工作不正常。比如React Native。

~/.npmrc
# https://pnpm.io/npmrc#node-linker
node-linker=hoisted

Yarn​

全局安装​

通过 NPM 安装​

npm install -g yarn

通过 brew 安装​

brew install yarn

常用命令​

安装依赖​

无论项目有没有用 yarn 初始化过 都可以直接用这个命令

# simple
yarn

# full
yarn install

执行 scripts 命令​

yarn {scripts command}

# e.g
yarn serve-dev