下載node
cd /mydata wget http://cdn.npm.taobao.org/dist/node/v10.16.1/node-v10.16.1.tar.gz
解壓npm
cd /mydata tar -zxf node-v10.16.1.tar.gz
建立安裝路徑this
mkdir /usr/local/node/
設置安裝路徑debug
sudo ./configure --prefix=/usr/local/node/
編譯安裝code
sudo make sudo make install
增長環境變量cdn
export NODEJS_HOME=/usr/local/node export PATH=$PATH:$NODEJS_HOME/bin
注意,全程都要用sudo權限,避免目錄沒法安裝get
查看安裝狀況it
monster@monster-PC:~$ node -v v10.16.1 monster@monster-PC:~$ npm -v 6.9.0
TroubleShotio
monster@monster-PC:~$ npm install -g cnpm --registry=https://registry.npm.taobao.org npm WARN checkPermissions Missing write access to /usr/local/node/lib/node_modules npm ERR! path /usr/local/node/lib/node_modules npm ERR! code EACCES npm ERR! errno -13 npm ERR! syscall access npm ERR! Error: EACCES: permission denied, access '/usr/local/node/lib/node_modules' npm ERR! { [Error: EACCES: permission denied, access '/usr/local/node/lib/node_modules'] npm ERR! stack: npm ERR! 'Error: EACCES: permission denied, access \'/usr/local/node/lib/node_modules\'', npm ERR! errno: -13, npm ERR! code: 'EACCES', npm ERR! syscall: 'access', npm ERR! path: '/usr/local/node/lib/node_modules' } npm ERR! npm ERR! The operation was rejected by your operating system. npm ERR! It is likely you do not have the permissions to access this file as the current user npm ERR! npm ERR! If you believe this might be a permissions issue, please double-check the npm ERR! permissions of the file and its containing directories, or try running npm ERR! the command again as root/Administrator (though this is not recommended). npm ERR! A complete log of this run can be found in: npm ERR! /home/monster/.npm/_logs/2019-08-05T09_20_52_374Z-debug.log
將目錄受權給當前用戶編譯
sudo chown -R monster:monster /usr/local/node