How to update NPM?

| By Webner

Learn how to update NPM?

NPM stands for Node Package Manager. It makes it easier for JavaScript developers to share and reuse the code. NPM is installed with Node and it is distributed with Node.js which means that when you download the Node.js package, you will automatically get NPM installed on your system. To check node and NPM version, you need to type following commands in the terminal:

> node -v
> npm -v

npm install installs the package and all other packages that it depends on. If the package has a package-lock or shrinkwrap file, the installation of dependencies will be driven from those files.

A package is defined as follows:
a) a folder containing a program described by a package.json file

b) a gzipped tarball containing (a)

c) a URL that resolves to (b)

d) a <name>@<version> that is published on the registry (see npm-registry) with (c)

e) a <name>@<tag> (see npm-dist-tag) that points to (d)

f) a <name>that has a “latest” tag satisfying (e)

g) a <git remote url> that resolves to (a)

“npm install” installs the dependencies in the local node_modules folder. With -g or –global appended to the command. It installs the current package as a global package. By default, “npm install” will install all modules listed as dependencies in package.json

The -f or –force argument will force npm to fetch remote resources even if a local copy exists on disk.
npm install sax –force
NPM is a different project from Node.js. As a result, even if you’ve just downloaded Node.js, you’ll probably need to update your NPM. Luckily, NPM knows how to update itself. To update it, type this command into your terminal:
> npm install npm@latest -g

In place of the latest keyword, you can specify the version number as well, that you want to install. Otherwise, by default, the latest version of NPM will be installed.

Leave a Reply

Your email address will not be published. Required fields are marked *