Tuesday, January 16, 2018

How to Install Node.js in Windows

Node.js is a JavaScript runtime which uses an event-driven, non-blocking I/O model.

Node.js can be an alternative to Java, PHP, .Net, Python, etc to develop web sites and applications using best convention frameworks such as Express.js, desktop applications using Electron.js, mobile apps using Ionic.js or React Native, to name a few of the possibilities.

Node.js is often referenced as just Node, but for easier internet searching, it is best to stick with nodejs.

Note: Node.js can be installed on multiple platforms, but if you are going to use Node.js to develop mobile apps and you want to be able to use an hardware emulator to test your development, you will need to install Node.js in your Host computer, and not a Guest VM.

To install Node.js in Windows 10


Go to https://nodejs.org

You can either download the LTS (long term support) version or the current version. Normally you would think to grab the latest, but for Node.js, it is better to use the LTS version.
Click the LTS button and download Node.js.

If you click on the LTS schedule, you will see how long Node.js intends to support both versions.

As you can see, the Current version will no be supported for as long. Node.js is following the pattern of even releases are for production while odd releases are for development. Also, some Node.js frameworks, such as Ionic.js, do not work well with the Current version, due to library dependencies. It is best to use the LTS version unless you find a particular need for the Current.

Double click the Node.js version you downloaded (node-v8.9.3-x64.msi) to begin installation.
Click Next

The normal agree to everything which you will never read but it is required to install any software.
Click Next

Choose a installation directory
The default is C:\Program Files\nodejs

For development, it can be better to keep your tools under a common directory, such as C:\Dev\. Doing so facilitates backups, deletions, you will have less typing to get to a directory, etc
Click Change and select your installation location
Click Next

By default all the options are enabled, leave them so.
  • npm is a package manager for Node.js and other software; it is the common method of installing Node.js related frameworks and libraries.
  • Add to Path is import as you will need to use the command line at times with Node.js
Click Next

Actually start the installation
Click install

And your done installing.
Click Finish

To verify that Node.js was installed, open a command prompt
Start -> Run -> type cmd and press enter

Instead of the Windows command prompt, you may want to use ConsoleZ which gives you more developer friendly options, such as easier copy/paste, tabs, etc

Change the directory to where you installed Node.js
cd C:\Program Files\nodejs
or
cd C:\Dev\nodejs

Verify the version of Node.js
node -v
The output should be the same you installed

You can also check the version of npm
npm -v

To update npm and other Node.js libraries you will install,
npm update

There will probably be an update to npm at least

You now have Node.js installed.

Your on your way to developing with frameworks such as Express.js, desktop applications using Electron.js, mobile apps using Ionic.js or React Native, to name a few of the possibilities.


End of document. Thanks for reading.

No comments:

Post a Comment