Build a Node. js + express web development framework under Ubuntu

Source: Internet
Author: User
Tags install node

This article mainly summarizes the articles written by the predecessors, including the problems encountered during the installation of node. js and express. For later use, while reducing the number of people learning node. js from detours.

1. The installation environment is of the cainiao level for linux. Therefore, you can install ubuntu11.10 on a virtual machine. The installation of the virtual machine is not mentioned here.

2. Install node. js: Step 1: Install the dependency package,

 
 
  1. sudo apt-get install g++ curl libssl-dev apache2-utils  
  2. sudo apt-get install git-core 

Step 2: Obtain the node source code

 
 
  1. git clone git://github.com/joyent/node.git 

After the download is complete, go to the cd node to enter the node folder,

Step 3: Specify the version to be migrated out: git checkout v0.4.10. git is a version management tool. We use git to move out of version 0.4.10, if the node is not migrated out, the latest version of node 0.5.5-pre will be installed. The latest version is not supported for many commonly used packages. For example, express, so pay attention to this place.

Step 4: Develop the path and execute the compilation

 
 
  1. $ Mkdir ~ /Local: Create a folder in the home directory of the current user
  2. $ Go to the decompressed configure folder and execute./configure -- prefix = $ HOME/local/node to set the compiling path.
  3. $ Make compilation.
  4. $ Sudo make install.
  5. $ Echo 'export PATH = $ HOME/local/node/bin: $ path'> ~ /. Profile set Environment Variables
  6. $ Echo 'export NODE_PATH = $ HOME/local/node: $ HOME/local/node/lib/node_modules '> ~ /. Profile set NODE_PATH
  7. $ Source ~ /. Profile

Now we can run node-v to check whether the installation is successful. Note that the environment variable settings here are temporary.

Step 5: Set permanent environment variables,

You can use the node command to set permanent environment variables even if you restart the machine. Enter/etc vi profile and append two lines at the end:

 
 
  1. export PATH=”$HOME/local/node/bin:$PATH”  
  2. export NODE_PATH=”$HOME/local/node:$HOME/local/node/lib/node_modules” 

OK. Now the node. js installation is complete.

3. Install express

Install npm: run the following command:

 
 
  1. curl http://npmjs.org/install.sh | sh 

Install express:

 
 
  1. npm install express -gd 

-G indicates to install it in the lib of NODEPATH, and-d indicates to install dependency suites together. If no-g exists, the current directory will be installed (A nodemodules folder will be created)

Run express-v to check whether the installation is successful. The installation of express has been completed.

Execute express xxx in any directory to create a node. js + express project.

Original article: http://club.cnodejs.org/topic/4f28f02b40b803737e018502

Related Article

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.