Linux installation Nodejs First, Introduction
English website: https://nodejs.org/en/download/
English Address: http://nodejs.cn/download/
uname -a
See my Linux system by command the number of bits is 64 bits (note: x86_64 represents 64-bit system, i686 i386 represents 32-bit system),
$ uname-alinux jchl-test-04 3.10. 0-514.6. 2.el7. X86_64 #1 SMP Thu Feb 23 03:04:39 UTC 2017 x86_64 Span class= "Hljs-keyword" >x86_64 X86_64 gnu/linux
Second, through the compilation of installation package installation (recommended) 2.1, to the official website to download and its own system matching files:
https://nodejs.org/en/download/
So download the red box file, version v6.11.3
2.2, download the tar file uploaded to the server and unzip, and then through the establishment of a soft connection into the global; 1) the upload server can be its own arbitrary path, the current my placement path is
/usr/local/
cd /usr/local/
2) Unzip the upload (unzip the file I will change the name to Nodejs, this place own arbitrary, as long as the establishment of a soft connection when the right to write it)
node-v8.4.0-linux-x64.tar.xz$ tar -xvf node-v8.4.0-linux-x64.tar.gz $ mv node-v8.4.0-linux-x64 nodejs
After you have finished extracting the installation files for node, you need to configure the environment variables, edit /etc/profile
, add
# set node environmentexport NODE_HOME=/usr/local/nodejsexport PATH=$PATH:$NODE_HOME/bin
Don't forget to do the following immediately
source /etc/profile
Confirm that the Nodejs Bin directory has node and NPM files, if there is a soft connection to perform, if there is no re-download to perform the top step;
3) Create a soft connection and become a global
/usr/local/nodejs/bin/npm /usr/local/bin/ ln -s /usr/local/nodejs/nodejs/bin/node /usr/local/bin/
4) The final step verifies whether the Nodejs has changed to a global
The linux command line node -v
command will display the Nodejs version for the finished
$ echo $NODE_HOME/usr/local/nodejs
node -vv6.11.1
$ npm -v5.3.0
If the speed is slow or the installation fails, you can use a domestic mirror:
npm install -g cnpm --registry=https://registry.npm.taobao.org
$ cnpm-v[email Protected]5.1.1 (/usr/local/nodejs/lib/node_modules/cnpm/lib/parse_argv.js) [email protected]5.4.2 (/usr/local/nodejs/lib/node_modules/cnpm/node_modules/npm/ lib/npm.js) [Email protected]8.4. 0 (/usr/local/nodejs/bin/node) [ Email protected] (/usr/local/nodejs/lib/node_modules/ Cnpm/node_modules/npminstall/lib/ Index. js) prefix=/usr/local/nodejs Linux x64 3.10.0-514.6.2.el7.x86_64 registry=http://registry.npm.taobao.org
2.3, Installation Grunt
$ sudo cnpm install -g grunt-cli$ cnpm install grunt
$ grunt -versiongrunt-cli v1.2.0grunt v1.0.1
2.4 Uninstalling node. js
Remove once with your own package management
remove nodejs npm -y
And so on, see what package management your operating system uses, such as launching if you are using brew to install node, you need to remove the residue manually by using brew first
Go to /usr/local/lib
Delete all node
and node_modules
folders
Go to /usr/local/include
Delete all node
and node_modules
folders
Check the "local" "Lib" "include" folder in the ~ folder, and then delete all the "node" and "Node_modules" folders inside.
You can use the following command to find
node find ~/ -name node_modules
Go /usr/local/bin
node
to the deleted executable file
The following steps are optional:
Delete:/usr/local/bin/npm
Delete:/usr/local/share/man/man1/node.1
Delete:/usr/local/lib/dtrace/node.d
Delete: rm -rf /home/[homedir]/.npm
Delete:rm -rf /home/root/.npm
Third, the source installation
Linux installation Nodejs