- Node Web Development(Second Edition)
- David Herron
- 589字
- 2021-08-13 16:46:52
Installing Node using package managers
The preferred method for installing Node, now, is to use the versions available in package managers such as apt-get, or MacPorts. Package managers simplify your life by helping to maintain the current version of the software on your computer and ensuring to update dependent packages as necessary, all by typing a simple command such as apt-get update
. Let's go over this first.
Installing on Mac OS X with MacPorts
The MacPorts project (http://www.macports.org/) has for years been packaging a long list of open source software packages for Mac OS X, and they have packaged Node. After you have installed MacPorts using the installer on their website, installing Node is pretty much this simple:
$ sudo port search nodejs nodejs @0.10.6 (devel, net) Evented I/O for V8 JavaScript nodejs-devel @0.11.2 (devel, net) Evented I/O for V8 JavaScript Found 2 ports. -- npm @1.2.21 (devel) node package manager $ sudo port install nodejs npm .. long log of downloading and installing prerequisites and Node
Installing on Mac OS X with Homebrew
Homebrew is another open source software package manager for Mac OS X, which some say is the perfect replacement for MacPorts. It is available through their home page at http://mxcl.github.com/homebrew/. After installing Homebrew using the instructions on their website, using it to install Node is as simple as this:
$ brew search node leafnode node $ brew install node ==> Downloading http://nodejs.org/dist/v0.10.7/node-v0.10.7.tar.gz ######################################################################## 100.0% ==> ./configure –prefix=/usr/local/Cellar/node/0.10.7 ==> make install ==> Caveats Homebrew installed npm. We recommend prepending the following path to your PATH environment variable to have npm-installed binaries picked up: /usr/local/share/npm/bin ==> Summary /usr/local/Cellar/node/0.10.7: 870 files, 16M, built in 21.9 minutes
Installing on Linux from package management systems
While it's still premature for Linux distributions or other operating systems to prepackage Node with their OS, that doesn't mean you cannot install it using the package managers. Instructions on the Node wiki currently list packaged versions of Node for Debian, Ubuntu, OpenSUSE, and Arch Linux.
See: https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager
For example, on Debian sid (unstable):
# apt-get update # apt-get install nodejs # Documentation is great.
And on Ubuntu:
# sudo apt-get install python-software-properties # sudo add-apt-repository ppa:chris-lea/node.js # sudo apt-get update # sudo apt-get install nodejs npm
We can expect in due course that the Linux distros and other operating systems will routinely bundle Node into the OS like they do with other languages today.
Installing the Node distribution from nodejs.org
The nodejs.org website offers prebuilt binaries for Windows, Mac OS X, Linux, and Solaris. You simply go to the website, click on the Install button, and run the installer. For systems with package managers, such as the ones we've just discussed, it's preferable to use that installation method. That's because you'll find it easier to stay up-to-date with the latest version. However, on Windows this method may be preferred.

For Mac OS X, the installer is a PKG file giving the typical installation process. For Windows, the installer simply takes you through the typical install wizard process.

Once finished with the installer, you have a command line tool with which to run Node programs.
The pre-packaged installers are the simplest ways to install Node, for those systems for which they're available.
Installing Node on Windows using Chocolatey Gallery
Chocolatey Gallery is a package management system, built on top of NuGet. Using it requires a Windows machine modern enough to support the Powershell and the .NET Framework 4.0. Once you have Chocolatey Gallery (http://chocolatey.org/), installing Node is as simple as this:
C:\> cinst install nodejs
- Flask Web全棧開發(fā)實戰(zhàn)
- Clojure Programming Cookbook
- 信息可視化的藝術(shù):信息可視化在英國
- .NET 4.0面向?qū)ο缶幊搪劊夯A(chǔ)篇
- Java加密與解密的藝術(shù)(第2版)
- Python Game Programming By Example
- 快速念咒:MySQL入門指南與進階實戰(zhàn)
- SharePoint Development with the SharePoint Framework
- C#程序設(shè)計
- 基于SpringBoot實現(xiàn):Java分布式中間件開發(fā)入門與實戰(zhàn)
- jQuery從入門到精通(微課精編版)
- Yii2 By Example
- 游戲設(shè)計的底層邏輯
- Practical Responsive Typography
- 軟件再工程:優(yōu)化現(xiàn)有軟件系統(tǒng)的方法與最佳實踐