sudo apt-get install npm
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
sudo ln -sf /usr/local/n/versions/node/<VERSION(只有數字沒有v)>/bin/node /usr/bin/node
方法2.
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt install -y nodejs
方法3.
wget https://nodejs.org/dist/v4.4.7/node-v4.4.7-linux-x86.tar.xz
2.xz -d node-v4.4.7-linux-x86.tar.xz
3.tar xvf node-v4.4.7-linux-x86.tar
4.export PATH=$PATH:/home/IXD/node-v4.4.7-linux-x86
或是直接讓每次開機加入路徑
echo 'PATH=$PATH:/opt/nodejs/bin' >> ~/.bashrc
5.之後輸入nodejs即可(非node)
安裝NPM
sudo apt-get install npm
之後輸入npm即可
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
使用scripts標籤下加入名稱,可使用npm run +名稱
{
"name": "class1webpack",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "webpack",
"dev": "webpack-dev-server --devtool eval --progress --colors --hot --content-base build"
},
"author": "Eason",
"license": "ISC",
"dependencies": {
"webpack": "^1.12.13",
"webpack-dev-server": "^1.14.1"
}
}