-
Notifications
You must be signed in to change notification settings - Fork 3
Installation
You may build the Node.js engine for any of the supported platforms.
For Windows and Mac some pre-built binaries are available; you may install them without building Node for yourself.
-
GNU make 3.81 or newer. Pre-installed on most systems. Sometimes called
gmake
. -
python 2.6 or 2.7. The build tools distributed with Node run on python.
-
libssl-dev (Node v0.6.x only.) Can usually be installed on *NIX systems with your favorite package manager. Pre-installed on OS X.
-
libexecinfo (FreeBSD and OpenBSD only.) Required by V8.
pkg_add -r libexecinfo
installs it.
On UNIX platforms, make sure that the path doesn't contain whitespace: /home/user/My Projects/node
won't work.
If you receive an error during ./configure
like this
File "/home/flo/node-v0.6.6/tools/waf-light", line 157, in <module>
import Scripting
File "/home/flo/node-v0.6.6/tools/wafadmin/Scripting.py", line 146
except Utils.WafError, e:
^
SyntaxError: invalid syntax
it is because Python3 is your default Python version. To fix this issue you have to set Python2 temporary as your default Python:
export PYTHON=`which python2`
Maybe you need to change your PYTHONHOME
as well. If that doesn't work, you can try creating symlinks to the old python in a directory which comes before python's in $PATH:
cd /usr/local/bin
ln -s /usr/bin/python2 python
ln -s /usr/bin/python2-config python-config
Remember to remove the symlinks when you're done. If you have any further installation problems stop into #node.js on irc.freenode.net and ask questions.
If you are compiling on a NFS mount and get errors at the linker stage, try this:
make LINK=g++
There's a number of ways to install Node.js on Linux, instructions for installing Node.js on specific Linux distributions using a package manager can be found at: Installing Node.js via package manager.
The filenames vary with the Node's version. The following examples are for Node v0.6.18.
Do something like this
tar -zxf node-v0.6.18.tar.gz #Download this from nodejs.org
cd node-v0.6.18
./configure && make && sudo make install
Or, if you'd like to install from the repository
git clone https://github.com/joyent/node.git
cd node
git checkout v0.6.18 #Try checking nodejs.org for what the stable version is
./configure && make && sudo make install
You may wish to install Node in a custom folder instead of a global directory.
./configure --prefix=/opt/node && make && sudo make install
You can really speed up building process by adding -j
argument with a number usually approximately equals number of cores plus one, so make -j 3
would be appropriate for dual-core processor.
You may want to put the node executables in your path as well for easier use. Add this line to your ~/.profile
or ~/.bash_profile
or ~/.bashrc
or ~/.zshenv
export PATH=$PATH:/opt/node/bin
If you have SpiderMonkey installed, you may have some conflicting includes. Set CXXFLAGS="-I./deps/v8/src"
before building to prioritize the v8 files over SpiderMonkey's.
Or use the one liner to install the latest node.js : bash < <(curl http://h3manth.com/njs)
It's easiest to use a package manager (as mentioned above) such as brew or macports.
-
Install Command Line Tools
Xcode: Preferences->Downloads install Command Line Tools
Note: I installed Xcode 4.5 in/Applications/Xcode
-
Download node.js src code
git clone https://github.com/joyent/node.git
cd node
git checkout v0.8.2
- Compiling Source Code
export CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
export CXX=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++
./configure && make && sudo make install
You need python and Microsoft Visual Studio but not OpenSSL. In cmd.exe
do the following
C:\Users\ryan>tar -zxf node-v0.6.5.tar.gz
C:\Users\ryan>cd node-v0.6.5
C:\Users\ryan\node-v0.6.5>vcbuild.bat release
[Wait 20 minutes]
C:\Users\ryan\node-v0.6.5>Release\node.exe
> process.versions
{ node: '0.6.5',
v8: '3.6.6.11',
ares: '1.7.5-DEV',
uv: '0.6',
openssl: '0.9.8r' }
>
The executable will be in Release\node.exe
.
You may obtain pre-compiled Node.js binaries for several platforms from http://nodejs.org/download.
Installing Node manually is recommended as a workaround for any problems with automatic install. You also have much better understanding of the things that happen if you do those things yourself.
The http://nodejs.org/dist/latest/ directory contains executables of the last version of Node.js engine (the engine only, i.e. without npm):
-
32bit version: http://nodejs.org/dist/latest/node.exe
-
64bit version: http://nodejs.org/dist/latest/x64/node.exe
The http://nodejs.org/dist/npm/ directory contains the latest .zip
archive of npm (such as npm-1.1.16.zip
when npm v1.1.16 was the latest).
Manual installation steps:
-
Make a clean directory and add that directory to your system's
PATH
variable. -
Download the latest
node.exe
to that directory. -
Download the latest npm's
.zip
file and unpack its contents to the same directory.
Then, with the usual help of PATH
, you'll be able to run scripts (node scriptname.js
) and install modules (npm install modulename
) in any directory.
To update Node, download the latest http://nodejs.org/dist/latest/node.exe file and replace your old node.exe
with it.
To update npm, run the npm update npm -g
command.
The http://nodejs.org/dist/latest/ directory contains the latest .msi
package (such as node-v0.6.15.msi
when Node v0.6.15 was the latest) that you may use to install both Node.js engine and npm.
The http://nodejs.org/dist/latest/ directory contains the latest .pkg
package (such as node-v0.6.15.pkg
when Node v0.6.15 was the latest).
You can download the latest .pkg
and run the installer and it will overwrite the existing version of Node currently installed.