- Web Development with MongoDB and NodeJS(Second Edition)
- Mithun Satheesh Bruno Joseph D'mello Jason Krol
- 799字
- 2021-07-09 21:13:00
Installing Node.js
The Node.js installer can be easily obtained by visiting the official Node website and accessing the downloads section. Once there, be sure to download the correct version depending on your OS and CPU (32 bit or 64 bit). As an alternative, you can also use OS-specific package managers to install this. Depending on the OS you are using, just jump into the specific subsection below to get more details on the steps to be followed.
Note
You can jump into the Node.js download sections by following the link http://nodejs.org/download.
Mac OS X
There is a universal installer available from the Node website specifically for OS X.
We need to follow these steps to install Node.js on a Mac:
- Visit the download page of the Node.js official website as mentioned earlier and click on the Mac OS X installer, which is independent of the processor type (32 or 64 bit).
- Once the download is complete, double-click on the
.pkg
file, which will launch the Node installer. - Proceed through each step of the wizard that should be fairly self-explanatory.

Windows
To install Node.js on Windows, we will follow these steps:
- We need to determine your processor type, 32 or 64 bit. You can do this by executing the following command at the command prompt:
$ wmic os get osarchitecture
The output is as follows:
OSArchiecture 64-bit
- Download the installer depending on the result of this command.
- Once the download is complete, double-click on the
.msi
file, which will launch the Node installer. - Proceed through each step of the wizard.
- When you get to the custom setup screen, you should notice that the installation wizard will install not only the Node.js runtime, but also the npm package manager, and configure a PATH variable.
- So once the installation is done, Node and npm can be executed from any folder via the command line.
Also, if you have any of the Windows package managers installed, then you don't need to manually download the installer. You may install Node.js via the respective package manager:
- Using chocolatey
cinst nodejs.install
- Using scoop
scoop install nodejs
Linux
Because there are so many different flavors and distributions of Linux available, installing Node isn't quite as straightforward. However, if you're running Linux to begin with, then you are more than aware of this and probably comfortable with a few extra steps.
Joyent has an excellent wiki on how to install Node on Linux using the many different package manager options available. This covers almost all the popular deb
and rpm
based package managers. You can read that wiki by visiting:
https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager
For Ubuntu 12.04 and above as an example, the steps to install Node would be as follows:
$ sudo apt-get update $ sudo apt-get install python-software-properties python g++ make $ sudo add-apt-repository ppa:chris-lea/node.js $ sudo apt-get update $ sudo apt-get install nodejs nodejs-dev npm
Once these steps have been completed, both Node and npm should be installed on your system.
Testing whether Node.js is installed properly
Now that Node has been installed on your system, let's run a quick test to ensure everything is working properly.
Access a command line via your terminal program and execute the following command:
$ node --version v0.10.35
$ npm --version 2.1.14
Assuming that your Node installation was successful, you should see the version number that was installed as an output on the screen right below the command you executed.
You can also launch the Node repl
, a command-line shell that lets you execute JavaScript directly:
$ node > console.log('Hello world!') Hello World! Undefined [press Ctrl-C twice to exit]
Online documentation
You'll want to be sure to point your browser to the online documentation for Node and bookmark it, as it will undoubtedly become a resource that you will want to access on a regular basis. It is not mandatory that you should go through each and every section of it, but once you start writing code in Node.js, you will need to refer to this document frequently to understand more on the apis
exposed by Node.js. The document is available at: http://nodejs.org/api/.
Also, check out the npm registry available at http://npmjs.com where you can find tens of thousands of modules available for Node developers.
- 深度實(shí)踐OpenStack:基于Python的OpenStack組件開發(fā)
- C# Programming Cookbook
- Java加密與解密的藝術(shù)(第2版)
- 云原生Spring實(shí)戰(zhàn)
- Python Network Programming Cookbook(Second Edition)
- MySQL數(shù)據(jù)庫(kù)管理與開發(fā)實(shí)踐教程 (清華電腦學(xué)堂)
- Full-Stack React Projects
- Python機(jī)器學(xué)習(xí)實(shí)戰(zhàn)
- Reactive Programming With Java 9
- HTML5+CSS3網(wǎng)站設(shè)計(jì)基礎(chǔ)教程
- Apache Mesos Essentials
- Unity 2018 Augmented Reality Projects
- 軟件工程基礎(chǔ)與實(shí)訓(xùn)教程
- Learning D3.js 5 Mapping(Second Edition)
- Android熱門應(yīng)用開發(fā)詳解