Skip to content

Install NodeJS

Kurt Junghanns edited this page Mar 10, 2016 · 4 revisions

Language Framework Virtualization

Linux


Fedora

There are two ways of installing NodeJS on Fedora. The easy way is to enable this COPR Repo and subsequently install node and npm via: source ~/.profile

dnf copr enable nibbler/nodejs
dnf install nodejs npm

You'll be always up to date with the latest stable version of NodeJS and NPM. Unfortunately, this COPR repo can cause incompatibilities with potentially installed software, because your overriding your distributors version. Keep that in mind!

When you don't want to override your distributors version of NodeJS and NPM, execute this Gist at your system as a bash script. Remember to update the NodeJS version inside the script to match the latest stable version. In Order to Update, you have to repeat all these steps by yourself. --> Watch out for any errors or warnings (typically occuring when you've already installed a version of NodeJS). Maybe you'll have to do some things by yourself. I've noticed that using sudo update-alternatives --config node and sudo update-alternatives --config npm helps in many cases. Maybe you have to invest a little more by using update-alternatives. Alternatively re-/moving your node bin (which node) can also be helpful.

Ubuntu

Since I have no Ubuntu, I can only describe what should be possible.

You can install NodeJS and NPM from your distributors repositories using apt-get. This may result in an old version of both.

Alternatively you can enable some PPA, delivering the latest version of NodeJS. Remember that this can cause incompatibilities with potentially installed software, because your overriding your distributors version.

The third way is to execute this Gist at your system as a bash script. Please exchange dnf commands with according apt-get commands and read the according alternative text regarding Fedora. It's the same procedure (as every year :P)

Currently working approach: First: https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions Second: https://docs.npmjs.com/getting-started/fixing-npm-permissions

Windows and Mac


To install NodeJS on Windows or Mac, visit this page, download the appropriate .msi (Windows) or .pkg (Mac) file and execute it on your machine.

Docker


Alternatively you can use the following commands on your commandline to run a Docker container, containing NodeJS, to execute your scripts. Remember to alter paths and variables to match your cases. The Docker container will start your program as a webserver on port 8880 (make sure that this port isn't in use!) or just executes it on commandline.

docker run -it --rm -v /PATH_TO_YOUR_APP:/usr/src/app -w /usr/src/app -p 8880:80 node:5.7-slim node YOUR_SCRIPT.js
Clone this wiki locally