Centos 7 offers NodeJS and NPM via yum install
. While this is great, it's not optimal because it pins
users to the version offered via yum. Moreover, a yum update
can easily upgrade the NodeJS version leading to all
kinds of breaking. Not what we want.
Luckily, nvm can help us.
In the same vain as rbenv
, rvm
or plenv
: this is a version manager that leaves the "system" node installation
alone and allows you to install and manage different versions of nodejs and npm concurrently.
Go to https://github.com/nvm-sh/nvm for the instructions.
Run this command to install nvm locally (warning: don't run this as root)
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
$ source .bashrc
NodeJS has a panoply of versions. Easiest is to install the latest LTS (long term support) version.
Why? Because once you start installing node modules via npm
you want to ensure compatibility with your
currently installed LTS version of NodeJS.
Consider that moving between LTS versions would be similar to moving between major versions of other languages (perl, ruby, python,...) causing breaking API changes.
Let's install the latest LTS version
$ nvm install --lts
$ node --version
v12.18.0
$ npm --version
6.14.4
Starting a project starts with npm init
. Without any extra arguments, it just creates a package.json file. But you could add a loader which will then create an entire directory structure depending on the type of project you want to work on: react, angular, etc.
Webpack manages the build pipelines of your project. Be it compiling SCSS files, transpiling ES code or building a React application.
$ npm install --save-dev webpack webpack-cli