1. Mac useful commands
ls # list files
ls -a # list files including .gitignore, _book, etc
1.1. kill port
macOS:
ps aux | grep node
lsof -i:3000
kill -9 <previous processId>
windows:
netstat -a -o -n
taskkill /F /PID <previous processId>
1.2. npm commands
npm init
npm install [-g] <packageName> [--save-dev]
npm start
npm t/test/tst
npm version major/minor/patch
yarn init
yarn add <packageName> [--dev]
1.2.1. npm-check-updates
npm install -g npm-check-updates
ncu # list
ncu -u # update package version
1.2.2. yarn
yarn config set registry https://registry.npm.taobao.org
yarn add <packageName> [--dev] # will automatically save package to devDependencies
yarn global add <packageName>
yarn eslint --init
# use yarn script instead npm run script
yarn dev
# upgrade all dependencies
yarn upgrade-interactive
yarn list --depth=0
1.2.3. nvm
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.6/install.sh | bash # install
nvm --version
nvm ls-remote # 查看所有node版本
nvm use v6.10.2 # 切换node版本
nvm alias default v6.10.2 # 将此版本设为默认
1.2.4. File operation
mkdir <folderName>
touch <newFile.js>
cat <newFile.js> # review file content
1.2.5. No access
sudo chown -R $USER /usr/lib/node_modules