NPM Basics

Published February 28, 2022 in Software Space by Brian Douglass
Filed under Nodejs, Links

NodeSource has recently released a 3-part blog series about NPM basics. This is a good resource for developers new to NPM and the package.json format. But it is a good refresher for experienced developers as well. I believe it is important to get back to the basics sometimes. I’ve also learned a few things from these articles.

The first post is: ”The Basics: Getting started with npm”. It goes over initializing a node project with NPM, installing dependencies, installing dev dependencies, and installing modules globally. One new thing I picked up was the npm init --yes command. This instantly generates a package.json without any inputs. Combine this with settings in your .npmrc file for the best experience. Here is an example of the configuration I have already been using: Douglass
[email protected]

Check out the NPM docs for further information about the .npmrc file options.

The second post is: ”The Basics of Package.json”. This goes over most of the parts of a package.json file, including dependencies and metadata-related fields. If you are interested in the full package.json schema, read more on the NPM docs.

The final post is: ”Understanding dependencies inside your Package.json”. It gives a brief overview of the various lesser-known dependency options. This includes PeerDependencies, OptionalDependencies, and BundledDependencies. Additionally, it goes over some of the host-related fields in a package.json file.

Check out the NodeSource Blog and subscribe to their RSS feed for more articles about Node.js!