- 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.
- HTML5+CSS3+JavaScript從入門到精通:上冊(微課精編版·第2版)
- Unity 2020 Mobile Game Development
- Hands-On JavaScript High Performance
- Mastering Python Networking
- R大數(shù)據(jù)分析實用指南
- Creating Stunning Dashboards with QlikView
- 從零開始學Linux編程
- 計算機應(yīng)用基礎(chǔ)案例教程
- PrimeFaces Blueprints
- Python開發(fā)基礎(chǔ)
- 精通Spring:Java Web開發(fā)與Spring Boot高級功能
- 零基礎(chǔ)學編程系列(全5冊)
- Python趣味創(chuàng)意編程
- Learning PrimeFaces Extensions Development
- 面向WebAssembly編程:應(yīng)用開發(fā)方法與實踐