Node.js Notes
NVM
GitHub
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| # 目前狀態 nvm ls
# 列出全部可以載的 nvm ls-remote
# 安裝 nvm install 6.6.6 nvm use 6.6.6
# 刪 nvm uninstall 6.6.6
# 載LTS nvm install lts/argon
# 設成default (重開會自動設成目前default) nvm alias default 4.5.0 nvm use default
|
NPM
Site
https://www.attosol.com/npm-notes-tips-tricks/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| # 自我更新 npm install npm -g
# 列出套件 npm ls npm ls -g npm ls -l npm ls -gl npm ls --depth=0 npm ls --depth=0 -g npm ls --depth=0 -l npm ls --depth=0 -gl npm ls --depth=0 -long -l npm ls --depth=0 -long -gl
# 更新套件 npm outdated npm outdated -g npm update npm update -g
# 製作套件 cd FOLDER npm link npm unlink or npm r xxxxx -g cd ANOTHER_FOLDER npm link xxxxx
# 上架 npm adduser 登入 npm whoami 看有沒有登入成功 npm publish 上架 npm unpublish --force 強制下架(三思) npm view 看發佈過的版本
# Script Shortcut npm start npm restart npm stop npm test
# 列出available scripts in the package.json: npm run # npm run-script
|
SemVer (Semantic Version)
1 2 3 4 5 6 7 8
| # Bug Fix && Little Change npm version patch
# New Feature npm version minor
# New Release npm version major
|
package.json
^1.2.3
: 1.x.x
( ≥1.2.3
& <2.0.0
)
~1.2.3
: 1.2.x
( ≥1.2.3
& <1.3.0
)
Yarn
Site
GitHub
1 2 3 4 5 6 7 8
| npm install yarn -g yarn install (= yarn) yarn init yarn add xxx (=npm install xxx -S) yarn add xxx -D (=npm install xxx -D) yarn upgrade (update all pkg in yarn.lock) yarn upgrade xxx (update package.json) yarn remove xxx (remove from package.json)
|