- Learning Node.js for Mobile Application Development
- Stefan Buttigieg Milorad Jevdjenic
- 591字
- 2021-07-09 21:21:29
Installing Node.js on different systems
Node.js is delivered as a set of JavaScript libraries, executing on a C/C++ runtime built around the Google V8 JavaScript Engine. The two come bundled together for most major operating systems (OS), and we will look at the specifics of installing it in the following sections.
Windows
For Windows, there is a dedicated MSI wizard to install Node.js, which can be downloaded from the project's official website. To do so, go to the main page, navigate to Downloads, and then select Windows Installer. After it has downloaded, run the MSI wizard, follow the steps to select the installation options, and conclude the install. Keep in mind that you will need to restart your system in order to make the changes effective.
Linux
Most major Linux distributions provide convenient installs of Node.js through their own package management systems. However, it is important to keep in mind that for many of them, Node Package Manager (NPM) will not come bundled with the main Node.js package. Rather, it is provided as a separate package. We will show how to install both in the following section.
Ubuntu/Debian
Open a terminal and issue sudo apt-get update
to make sure that you have the latest package listings. After this, issue apt-get install nodejsnpm
in order to install both Node.js and NPM in one swoop.
Fedora/RHEL/CentOS
On Fedora 18 or later, open a terminal and issue sudo yum install nodejsnpm
. The system will do the full setup for you.
If you are running RHEL or CentOS, you need to enable the optional EPEL repository. This can be done in conjunction with the install process, so that you do not need to do it again while upgrading the repository, by issuing the sudo yum install nodejsnpm --enablerepo=epel
command.
Verifying your installation
Now that we have finished the install, let's do a sanity check and make sure that everything works as expected. To do so, we can use the Node.js shell, which is an interactive runtime environment for the execution of JavaScript code. To open it, first open a terminal, and then issue the following to it:
node
This will start the interpreter, which will appear as a shell, with the input line starting with the >
sign. Once you are in it, type the following:
console.log("Hello world!);
Then press Enter. The Hello world! phrase should appear on the next line. Congratulations, your system is now set up for the running of Node.js!
Mac OS X
For OS X, you can find a ready-to-install PKG file by going to www.nodejs.org, navigating to Downloads, and selecting the Mac OS X Installer option. Otherwise, you can click on Install, and your package file will automatically be downloaded:

Once you have downloaded the file, run it and follow the instructions on the screen. It is recommended that you keep all the default settings offered unless there are compelling reasons for you to change something with regard to your specific machine.
Verifying your installation
After the install finishes, open a terminal and start the Node.js shell by issuing the following command:
node
This will start the interactive node shell, where you can execute JavaScript code. To make sure that everything works, try issuing the following command to the interpreter:
console.log("hello world!");
After pressing the Enter key, the hello world! phrase will appear on your screen. Congratulations, Node.js is all set up and good to go!
- Dynamics 365 for Finance and Operations Development Cookbook(Fourth Edition)
- TypeScript Blueprints
- Building a Home Security System with Raspberry Pi
- INSTANT FreeMarker Starter
- 看透JavaScript:原理、方法與實踐
- Architecting the Industrial Internet
- Python零基礎(chǔ)快樂學(xué)習(xí)之旅(K12實戰(zhàn)訓(xùn)練)
- bbPress Complete
- Python算法從菜鳥到達人
- C語言程序設(shè)計
- Arduino家居安全系統(tǒng)構(gòu)建實戰(zhàn)
- 利用Python進行數(shù)據(jù)分析
- Raspberry Pi Robotic Blueprints
- ExtJS Web應(yīng)用程序開發(fā)指南第2版
- C#面向?qū)ο蟪绦蛟O(shè)計(第2版)