ubuntu12.04 installation Nodejs "finishing"

Source: Internet
Author: User

ubuntu12.04 Install Nodejs Web front end Hangzhou-Little White

Liunx inside install Nodejs I also looked for a lot of articles, seemingly for a lot of liunx novice is not very clear, the following is I combine some articles, personally practice to get the installation steps. There are also concerns about the installation of SPM modules that are closely related to SEAJS. (Perhaps a lot of people in the liunx inside the Nodejs after loading the SPM module often error. Hey, look at this maybe know why.) (--! actually I do not understand liunx, so here is tossing a turn, everyone please see. I'm all in the virtual machine inside the Ubuntu test can be used .)

The first step is to install the Dependency Pack 1) to install the compiler and the running environment. Generally only use this is good. You can look at the back.

<textarea class="crayon-plain print-no" style="line-height: 15px !important; overflow: hidden; font-size: 12px !important; z-index: 0; opacity: 0; -moz-tab-size: 4; -o-tab-size: 4; -webkit-tab-size: 4; tab-size: 4;" readonly="" data-settings="dblclick">sudo apt-get install g++ curl Libssl-dev apache2-utils</textarea>
1 sudo apt-get install g+ + Curl libssl-Dev apache2- Utils

#这个下面的可以执行下看看. Anyway, make sure everything you need is already installed.

2). Make sure the system is installed to python,gcc,g++, if not installed:

<textarea class="crayon-plain print-no" style="line-height: 15px !important; overflow: hidden; font-size: 12px !important; z-index: 0; opacity: 0; -moz-tab-size: 4; -o-tab-size: 4; -webkit-tab-size: 4; tab-size: 4;" readonly="" data-settings="dblclick">sudo apt-get install pythonsudo apt-get install build-essentialsudo apt-get install gccsudo apt-get install g++</textarea>
1234 sudo apt-get install python sudo apt- get install build-< Span class= "crayon-e" >essential sudo apt-get install GCC sudo apt-get install g++

3). To install git, if you download the source code directly, Git can not be installed. Reserved.

<textarea class="crayon-plain print-no" style="line-height: 15px !important; overflow: hidden; font-size: 12px !important; z-index: 0; opacity: 0; -moz-tab-size: 4; -o-tab-size: 4; -webkit-tab-size: 4; tab-size: 4;" readonly="" data-settings="dblclick">sudo apt-get install Git-core</textarea>
1 sudo apt-get install git-core

The second step, get node source code to download the website directly: http://nodejs.org #解压

<textarea class="crayon-plain print-no" style="line-height: 15px !important; overflow: hidden; font-size: 12px !important; z-index: 0; opacity: 0; -moz-tab-size: 4; -o-tab-size: 4; -webkit-tab-size: 4; tab-size: 4;" readonly="" data-settings="dblclick">tar-zxf node-v0.8.17.tar.gz</textarea>
1 Tar -zxf node-v0. 8.17.tar.gz

#进入解压后的文件夹

<textarea class="crayon-plain print-no" style="line-height: 15px !important; overflow: hidden; font-size: 12px !important; z-index: 0; opacity: 0; -moz-tab-size: 4; -o-tab-size: 4; -webkit-tab-size: 4; tab-size: 4;" readonly="" data-settings="dblclick">CD node-v0.8.17</textarea>
1 CD node-v0. 8.17

Step three, compile, install 1) do not specify the installation path.

<textarea class="crayon-plain print-no" style="line-height: 15px !important; overflow: hidden; font-size: 12px !important; z-index: 0; opacity: 0; -moz-tab-size: 4; -o-tab-size: 4; -webkit-tab-size: 4; tab-size: 4;" readonly="" data-settings="dblclick">./configuremake (a bit slow here!) sudo make install</textarea>
123 . /Configure make (a little slower here !) sudo make install

[Note: This method is not recommended, it seems that there will be a lot of problems after installation. Because I am a LIUNX rookie. If you are Daniel do not think about my own, to solve the problem. haha!]

2) Specify the installation path: Execute the Configure command to set the installation directory (note: Specify the installation directory after the installation is complete. It's important! If your account is root, it's nonsense. If not, please note. How to set file permissions, later on. You can continue now. For example, install Nodejs in the/usr/local/node directory.

<textarea class="crayon-plain print-no" style="line-height: 15px !important; overflow: hidden; font-size: 12px !important; z-index: 0; opacity: 0; -moz-tab-size: 4; -o-tab-size: 4; -webkit-tab-size: 4; tab-size: 4;" readonly="" data-settings="dblclick">./configure--prefix=/usr/local/node</textarea>
1 . /Configure --prefix=/usr/local/node

#运行make命令编译源代码, then run the Make install command to install Nodejs

<textarea class="crayon-plain print-no" style="line-height: 15px !important; overflow: hidden; font-size: 12px !important; z-index: 0; opacity: 0; -moz-tab-size: 4; -o-tab-size: 4; -webkit-tab-size: 4; tab-size: 4;" readonly="" data-settings="dblclick">Makesudo make install</textarea>
12 Make sudo make install

Fourth step, set environment variable 1) If you do not set environment variables, you will only be able to run node in the/usr/local/node/bin directory

<textarea class="crayon-plain print-no" style="line-height: 15px !important; overflow: hidden; font-size: 12px !important; z-index: 0; opacity: 0; -moz-tab-size: 4; -o-tab-size: 4; -webkit-tab-size: 4; tab-size: 4;" readonly="" data-settings="dblclick">export path= $PATH:/usr/local/node/bin</textarea>
1 Export Path=$path:/usr/local/node/bin

[Note: Each open terminal to run the above command, trouble! So we recommend using the following 2.--!]

2) Add the path of node to the environment variable so that you can call the node command directly after opening the shell. For Ubuntu, it is a common practice to edit the current user's profile. bashrc file, add the following script to the end of the file:

<textarea class="crayon-plain print-no" style="line-height: 15px !important; overflow: hidden; font-size: 12px !important; z-index: 0; opacity: 0; -moz-tab-size: 4; -o-tab-size: 4; -webkit-tab-size: 4; tab-size: 4;" readonly="" data-settings="dblclick">path= "/usr/local/node/bin: $PATH"</textarea>
1 PATH="/usr/local/node/bin: $PATH"

[Note: If you use the graphical interface, open the file browser, click Ctrl+h, will show the hidden files, so that you can find the. bashrc file, I use this way.]

Fifth step, test whether node is installed successfully//Display node version number, indicating successful installation

<textarea class="crayon-plain print-no" style="line-height: 15px !important; overflow: hidden; font-size: 12px !important; z-index: 0; opacity: 0; -moz-tab-size: 4; -o-tab-size: 4; -webkit-tab-size: 4; tab-size: 4;" readonly="" data-settings="dblclick">node-v</textarea>
1 Node -v

Other: For example: Install Express #记得一定要加-GD, or he will install to the current folder

<textarea class="crayon-plain print-no" style="line-height: 15px !important; overflow: hidden; font-size: 12px !important; z-index: 0; opacity: 0; -moz-tab-size: 4; -o-tab-size: 4; -webkit-tab-size: 4; tab-size: 4;" readonly="" data-settings="dblclick">npm Install EXPRESS-GD</textarea>
1 NPM Install Express -gd

The #-g representative is installed in the Lib of Node_path, and the-D represents the installation of the dependency kit. If you do not have-G will install the current directory (will create a node_modules folder), you can use the following instructions to compare the difference between the two:

<textarea class="crayon-plain print-no" style="line-height: 15px !important; overflow: hidden; font-size: 12px !important; z-index: 0; opacity: 0; -moz-tab-size: 4; -o-tab-size: 4; -webkit-tab-size: 4; tab-size: 4;" readonly="" data-settings="dblclick">NPM LIST-GNPM List</textarea>
12 npm list -g npm list

File permission settings (note: Is for non-root account.) :

You can see the path to step three. Here's how to set folder permissions before I install SPM: #进入local目录

<textarea class="crayon-plain print-no" style="line-height: 15px !important; overflow: hidden; font-size: 12px !important; z-index: 0; opacity: 0; -moz-tab-size: 4; -o-tab-size: 4; -webkit-tab-size: 4; tab-size: 4;" readonly="" data-settings="dblclick">cd/usr/local</textarea>
1 CD /usr/local

#给node文件夹可读可写的权限

<textarea class="crayon-plain print-no" style="line-height: 15px !important; overflow: hidden; font-size: 12px !important; z-index: 0; opacity: 0; -moz-tab-size: 4; -o-tab-size: 4; -webkit-tab-size: 4; tab-size: 4;" readonly="" data-settings="dblclick">sudo chmod-r 777 node/</textarea>
1 sudo chmod -R 777 node/

[Note: This is how I do it, if you understand this yourself.]

#查看历史, if you want to see the BAI, do not look at the jump.

<textarea class="crayon-plain print-no" style="line-height: 15px !important; overflow: hidden; font-size: 12px !important; z-index: 0; opacity: 0; -moz-tab-size: 4; -o-tab-size: 4; -webkit-tab-size: 4; tab-size: 4;" readonly="" data-settings="dblclick">historyhistory | grep chmod</textarea>
12 History History | grep chmod

You can install the SPM with the right permissions, and it will not be a problem to install other modules (such as Express).

#回到根目录, can not return, casually

<textarea class="crayon-plain print-no" style="line-height: 15px !important; overflow: hidden; font-size: 12px !important; z-index: 0; opacity: 0; -moz-tab-size: 4; -o-tab-size: 4; -webkit-tab-size: 4; tab-size: 4;" readonly="" data-settings="dblclick">CD</textarea>
1 Cd

#开始安装, why to-gd the previous explanation, without-GD, there may be some problems, if you can solve the problem, then do not worry. If you add-gd here, then the previous folder permission steps must be given. The following command will not be executed without giving permission. You'll find out if you try it yourself. [Note: If the original account is root to skip these nonsense, hey!]

<textarea class="crayon-plain print-no" style="line-height: 15px !important; overflow: hidden; font-size: 12px !important; z-index: 0; opacity: 0; -moz-tab-size: 4; -o-tab-size: 4; -webkit-tab-size: 4; tab-size: 4;" readonly="" data-settings="dblclick">npm Install SPM-GD</textarea>
1 NPM Install SPM -gd

#然后一直等待 #完毕之后就是, view the version in uppercase. (Halo!) )

<textarea class="crayon-plain print-no" style="line-height: 15px !important; overflow: hidden; font-size: 12px !important; z-index: 0; opacity: 0; -moz-tab-size: 4; -o-tab-size: 4; -webkit-tab-size: 4; tab-size: 4;" readonly="" data-settings="dblclick">spm-v</textarea>
1 SPM -V

Output version this is OK.

The above is the chestnut in the catalogue set in my third step.

Finally, the Liunx loaded Nodejs, and the installation of the SPM process. Well, try it out for yourself. I hope the general novice, this can help you. If there is an error, please leave a message or @ me.--!

The latest version has been brought with NPM, so do not install, to be installed only SPM.

If you do not understand this, you can refer to the following links:

Http://www.cnblogs.com/objectorl/archive/2012/05/01/install-nodejs-on-ubuntu.html

http://www.lzlu.com/blog/?p=792

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.