Node.js and npm installation
The purpose of this section is to guide you to install Node.js in your development environment. Node.js is both a runtime and a framework. As a runtime, Node.js manages the execution of JavaScript code on the machine where it is installed. This machine could be a server in the cloud or could be any machine like your development machine.
Node.js provides a framework that you can use to develop connected JavaScript application.
Node.js provides an extensibility mechanism called Module. Node.js itself is designed as a set of core modules.
To install and use third-party modules you need a package installer. This package installer is called npm (Node Packet Manager). Though npm and Node.js are provided by two different legal entities, the node packet manager npm is bundled with the Node.js installer.
npm, like Node.js is a command-line application. This means it has no user interface. You invoke the tool inside a command prompt or inside a PowerShell window.
Command-line applications are often called CLI. Node.js provides a CLI which is a windows file called node.exe. To invoke this command-line, open a Command Prompt window (All apps-> Windows System -> Command Prompt) and type node:
Microsoft Windows [Version 10.0.10586]
(c) 2016 Microsoft Corporation. All rights reserved.
C:\Users\john>node
'node' is not recognized as an internal or external command, operable program or batch file.
If Node.js is not yet installed, you will get the above error message.
npm provides a CLI which is a windows npm.cmd batch file. To invoke this command-line, open a Command Prompt and type npm:
'npm' is not recognized as an internal or external command, operable program or batch file.
If Node.js is not yet installed, you will get the above error message.
You will see that NativeScript provides also a CLI which is a windows file called tns.exe. To invoke this command-line,open a Command Prompt and type tns:
C:\Users\john>tns
'tns' is not recognized as an internal or external command, operable program or batch file.
If NativeScript CLI is not yet installed, you will get the above error message.
A CLI has commands and options. A CLI commmand is a term that indicates an action. For example npm has a command called install that enables you to download and install third-party modules. To invoke this command:
C:\Users\john>npm install
CLI options enables you to customize the default behavior of the command. An option is often prefixed with a double dash. For example npm command install has an option called --global. To invoke this option:
C:\Users\john>npm install <package name> --global
the --global option will cause npm to install the package globally rather than locally.
More details of the Node.js CLI : https://nodejs.org/dist/latest-v6.x/docs/api/cli.html.
More details of the npm CLI : https://docs.npmjs.com/cli/help
Now its time to install the latest 64-bit version from https://nodejs.org/en/
To ensure that Node.js is ready to use, open a command window and type the command :
C:\Users\john>node -v
v6.3.1
This will show you the current version of the Node.js installation. If you get an error message, close the command prompt window and open a new one. If you still have an error reboot your machine.
To ensure that npm is ready to use, open a command window and type the command :
C:\Users\john>npm -v
3.5.3