Let’s Nurture, the leading Node.js development company is glad to have a recognition by Clutch platform as “The Best Web Development Company in Canada”. We all are aware about the MEAN Stack and its components. We are the best MEAN Stack web app development company in Ahmedabad, India and with our Node.js development team would like to share some inputs about Node.js installation on different Operating systems. This article will guide you for the Node.js installation on Microsoft Windows and Ubuntu.
Node.js Installation on Microsoft Windows
1. Download the Windows installer from the Nodes.js® web site.
2. Run the installer (the .msi file you downloaded in the previous step.)
3. Follow the prompts in the installer (Accept the license agreement, click the NEXT button a bunch of times and accept the default installation settings).
4. Restart your computer. You won’t be able to run Node.js® until you restart your computer.
Node.js Installation on an Ubuntu 14.04 Server
There are several different ways Node.js developers can install Node.js on your server. This guide will cover these different options including:
- APT package manager
- PPA (Personal Package Archive)
- NVM (Node Version Manager)
You can use whatever install method of Node.js that you prefer. If your Node.js application needs a specific version, or multiple versions, we suggest using NVM. Otherwise, if the current Node.js version works for you application, using APT is usually fine.
Install the Distro-Stable Version of Node.js with APT
Ubuntu 16 has Node.js in its default apt repositories. That version of Node.js can be used to provide a consistent experience across multiple servers.
1. Update your local package index:
sudo apt-get update
2. Install Node.js:
sudo apt-get install nodejs
3. You will also want to install NPM, which lets you easily manage your different Node.js packages.
sudo apt-get install npm
Install Using a PPA
Another way to get the most recent version of Node.js is to add a PPA (Personal Package Archive), which is maintained by NodeSource. If you don’t want to use the Node.js version in the APT repositories, this is a good alternative.
1. Install the PPA. This will give you access to its contents.
- For the most recent LTS (the 6.x branch), use:
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash –
- For the older LTS (the 4.x branch), use:
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash –
- For the currently active release (the 7.x branch), use:
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash –
2. The PPA will be added into your APT configuration, and your local package cache will be automatically updated. After you run the setup script from NodeSource, you can then use the previous steps to install the Node.js package with APT.
sudo apt-get install nodejs
Note: The Node.js package contains the Node.js binary as well as npm, so you don’t need to install npm separately. However, in order for some npm packages to work (such as those that require building from source), you will need to install the build-essentials package.
3. Install build-essentials:
sudo apt-get install build-essential
Install Node.js using NVM
Instead of using apt, you can install Node.js with a tool called nvm, which stands for “Node.js Version Manager”.
NVM lets you install multiple different versions of Node.js. This way, you have more control over your environment for whatever your project needs. NVM will also give you on-demand access to the latest versions of Node.js, and the ability to use previous releases that your application may be dependent on.
1. Run apt-get update:
sudo apt-get update
2. Install build-essentials:
sudo apt-get install build-essential libssl-dev
3. Download and install the installation script:
Download the nvm installation script from the project’s GitHub page:
https://raw.githubusercontent.com/creationix/nvm/master/install.sh | sh
This will download the script and execute it. It will install into a subdirectory of your home directory at ~/.nvm. It also adds the essential lines to your ~/.profile file to use the file with bash.
Note: This command will pull from the Github Master page so that it is always up to date, but you can use previous versions by finding the URL on that GitHub repository.
4. Update your current session:
5. List available Node.js versions.
Now that nvm is installed, you can install isolated Node.js versions:
. . .
6. Install the version of Node.js that you want to use. In this example, the newest version is v7.1.0. If you wanted to install V7.1.0 you can do so by using the nvm install command. If there is a newer version available, use that version.
nvm install 7.1.0
7. After the command runs, your desired version of Node.js will be installed.
Typically, nvm will default to the newest version, but you can explicitly tell nvm to use a previous version by using the following syntax – where the highlighted portion is the version you wish to run:
nvm use 7.0.0
When using nvm to install Node.js, the executable is simply called node. You can find out what Node.js version is being used by the shell by typing:
This will display the version being used:
If you have multiple versions of Node.js, you can determine the installed version by typing:
To set a specific Node.js as default, you can use the following syntax where the highlighted portion of the text is the desired version:
nvm alias default 7.1.0
That version will be automatically selected when a new session is generated. You can also reference it using an alias such as:
nvm use default
Each version of Node.js will keep track of its own packages and uses npm to manage them.
npm install express
If you want to make that package available globally to all your Node.js projects, you can simply add the -g flag:
npm install -g express
After that command has been run, the package will be installed in:
Using the global installation will allow you to run the commands from the command line. However, you will have to link the package into your local sphere to require it from within an application. In this example, we are linking Express.js to our current project:
npm link express
For any other information about the NVM command, you can use help:
Among the all Node.js installation on an Ubuntu server 14.04, nvm method is much more flexible. If you have any queries or doubts then please let us know in comments. We will be happy to help you. Also you can share your knowledge regarding this topic in below comment box.
We at Let’s Nurture have a team of MEAN Stack development experts who has years of experience in providing website application development services. If you wish to have your business web app to run in a smooth manner with interactive features then do contact us at email@example.com