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,
- sudo apt-get install g++ curl libssl-dev apache2-utils
- sudo apt-get install git-core
Step 2: Obtain the node source code
- 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
- $ Mkdir ~ /Local: Create a folder in the home directory of the current user
- $ Go to the decompressed configure folder and execute./configure -- prefix = $ HOME/local/node to set the compiling path.
- $ Make compilation.
- $ Sudo make install.
- $ Echo 'export PATH = $ HOME/local/node/bin: $ path'> ~ /. Profile set Environment Variables
- $ Echo 'export NODE_PATH = $ HOME/local/node: $ HOME/local/node/lib/node_modules '> ~ /. Profile set NODE_PATH
- $ 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:
- export PATH=”$HOME/local/node/bin:$PATH”
- 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:
- curl http://npmjs.org/install.sh | sh
Install express:
- 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