Additional Information
Important links and setting up Node.js locally.
We'll cover the following
Installing Node.js
Being cross-platform, Node.js is available on a number of different operating systems. Head over to their download page here to download it on your machine. You can choose between the
This course was written with Node.js 14.8, which was the latest version at the time of writing.
Installing packages
It is very easy to search for packages on the npmjs website. Most packages have very resourceful pages with links to the official documentation and the github pages. You can install packages using the following command.
npm install <package>
// for nodemon
npm install nodemon
To install a specific version of a package we can use the following command:
npm install <package>@<version>
// for nodemon
npm install nodemon@1.18.7
We can also specify the latest version of a minor or a patch if we want. Let’s say we want nodemon 1.19, and we don’t care about the patch. We can get the latest version of the patch by using the ~
.
// for nodemon
npm install nodemon@~1.18.7
This will install the latest version of 1.18, which is 1.18.11. We can do the same for the latest minor version using ^
.
// for nodemon
npm install nodemon@^1.18.7
This will install version 1.19.4 of nodemon, even though version 2.0.4 exists. The ^
gets the latest version of the minor, whilst keeping the major the same.
Here is a list of a few other flags for install
.
Flags | Explanation |
---|---|
-P, --save-prod |
This is the default behavior. This will save the package in your dependencies. |
-D, --save-dev |
This will save the package in your devDependencies. |
-O, --save-optional |
This will save the package in your optionalDependencies. |
--no-save |
The package will not be saved as a dependency. |
Packages can be uninstalled using the
uninstall
command. We can use the same flags as theinstall
command; however, instead of saving the package, we can choose to remove the package from our dependencies with the flags.
Updating packages
Packages can be updated easily with npm. We can use the update
command to update the packages.
npm update
The update
command has a couple of flags that can be used to modify its behavior. The --dev
flag also updates the devDependencies
. The -g
flag will update globally installed packages.
Docs
You can view the official documentation here. Since Node.js is always improving and getting new features, the documentation can be really useful for staying up to date. This website provides a nice overview of all the supported ECMAScript features in various versions of Node.js.
Get hands-on with 1400+ tech skills courses.