Node.js, NPM and Yarn

Installation

n to install Node.js and npm

curl -L https://raw.githubusercontent.com/tj/n/master/bin/n -o n
bash n lts

Install yarn v1.22.11

npm install --global yarn

nrm

使用 nrm https://github.com/Pana/nrm 可以让我们来切换不同的 npm 源而不用单独安装 cnpm 之类的库

npm install -g nrm
nrm ls # 列出当前支持切换的源
nrm use taobao # 使用 taobao 的源作为默认的 npm 源

ref:

  1. https://github.com/tj/n

  2. https://github.com/nvm-sh/nvm#installing-and-updating

Used Packages

lint-md, husky, gulp, npx, gatsby-cli, jest, docsify-cli, dclone

Yarn v2 Usage

npm install -g yarn # update the global yarn version to latest v1
cd yourproject
yarn set version berry # after this will generate .yarnrc.yml
# add `nodeLinker: node-modules` to .yarnrc.yml
# commit files:
# - .yarn/releases/yarn-berry.cjs
# - .yarnrc.yml
yarn install # migrate the lockfile

Add these to .gitignore(not using Zero-Installs)(or use my own .gitignore):

.yarn/*
!.yarn/patches
!.yarn/releases
!.yarn/plugins
!.yarn/sdks
!.yarn/versions
.pnp.*

Then commit everything remaining

ref: https://yarnpkg.com/getting-started/migration