# install nodejs npm - refer to https://segmentfault.com/a/1190000007542620 ### install and update ``` bash sudo apt install nodejs sudo apt install npm sudo npm install n@latest -g sudo n stable sudo npm install npm@latest -g node -v npm -v sudo npm install -g cnpm --registry=https://registry.npm.taobao.org #or npm config set registry https://registry.npm.taobao.org npm config get registry ``` - if error: /usr/bin/env: node: No such file or directory > ln -s /usr/bin/nodejs /usr/bin/node - if old nodejs still exist > sudo apt-get purge nodejs ### node && yarn ```bash # yarn curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list sudo apt-get update && sudo apt-get install yarn sudo yarn global add n sudo n stable ```