1. 程式人生 > >搭建 Nodejs 生產環境

搭建 Nodejs 生產環境

lib nss target creation get webpack source code 工具包

1、環境:阿裏雲ubuntu16.04

2、更新:sudo apt-get update

3、安裝相關依賴文件:

sudo apt-get install vim openssl build-essential libssl-dev wget curl git

4、安裝nvm

在 https://github.com/creationix/nvm 找到,並使用

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.5/install.sh | bash
下載完成後
source ~/.bashrc
完成後重新打開一個終端

技術分享

5、使用nvm 安裝 nodejs穩定版本(截至20171015)

nvm install 6.11.4

技術分享

技術分享

6、指定系統默認版本:

nvm use 6.11.4

技術分享

nvm alias default 6.11.4

技術分享

7、將npm源設置成淘寶源

npm --registry=https://registry.npm.taobao.org install -g npm

技術分享

監控文件數目:

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

8、安裝cnpm

npm --registry=https://registry.npm.taobao.org install -g cnpm

9、安裝常用全局工具包(按需選擇性安裝):

npm install pm2 webpack gulp grunt-cli -g

搭建 Nodejs 生產環境