- Node.js Web Development
- David Herron
- 381字
- 2021-06-25 21:54:00
Installing from source for all POSIX-like systems
Compiling Node.js from source follows this process:
- Download the source from http://nodejs.org/download.
- Configure the source for building using ./configure.
- Run make, then make install.
The source bundle can be downloaded with your browser, or as follows, substituting your preferred version:
$ mkdir src $ cd src $ wget https://nodejs.org/dist/v10.0.0/node-v10.0.0.tar.gz $ tar xvfz node-v10.0.0.tar.gz $ cd node-v10.0.0
Now we configure the source so that it can be built. This is just like many other open source packages, and there are a long list of options to customize the build:
$ ./configure --help
To cause the installation to land in your home directory, run it this way:
$ ./configure --prefix=$HOME/node/10.0.0 ..output from configure
If you're going to install multiple Node.js versions side by side, it's useful to put the version number in the path like this. That way, each version will sit in a separate directory. It's a simple matter of switching between Node.js versions by changing the PATH variable appropriately:
# On bash shell:
$ export PATH=${HOME}/node/VERSION-NUMBER/bin:${PATH}
# On csh
$ setenv PATH ${HOME}/node/VERSION-NUMBER/bin:${PATH}
A simpler way to install multiple Node.js versions is the nvm script described later.
If you want to install Node.js in a system-wide directory, simply leave off the --prefix option and it will default to installing in /usr/local.
After a moment, it'll stop and will likely have successfully configured the source tree for installation in your chosen directory. If this doesn't succeed, the error messages that are printed will describe what needs to be fixed. Once the configure script is satisfied, you can go on to the next step.
With the configure script satisfied, you compile the software:
$ make .. a long log of compiler output is printed $ make install
If you are installing into a system-wide directory, do the last step this way instead:
$ make $ sudo make install
Once installed, you should make sure that you add the installation directory to your PATH variable as follows:
$ echo 'export PATH=$HOME/node/10.0.0/bin:${PATH}' >>~/.bashrc $ . ~/.bashrc
Alternatively, for csh users, use this syntax to make an exported environment variable:
$ echo 'setenv PATH $HOME/node/10.0.0/bin:${PATH}' >>~/.cshrc $ source ~/.cshrc
This should result in some directories, as follows:
$ ls ~/node/10.0.0/ bin include lib share $ ls ~/node/10.0.0/bin
- 數(shù)字媒體應(yīng)用教程
- Power Up Your PowToon Studio Project
- Unity 2020 Mobile Game Development
- The React Workshop
- Mastering Apache Spark 2.x(Second Edition)
- The DevOps 2.5 Toolkit
- Windows Phone 7.5:Building Location-aware Applications
- Lighttpd源碼分析
- 微信小程序開發(fā)與實戰(zhàn)(微課版)
- Scala Data Analysis Cookbook
- Python Data Science Cookbook
- Odoo 10 Implementation Cookbook
- Managing Microsoft Hybrid Clouds
- Hands-On Dependency Injection in Go
- PHP動態(tài)網(wǎng)站開發(fā)實踐教程