Also known as Node Package Manager
Used to install dependencies, share and consume useful and reusable code
Originally used as a package manager for Node.js (which is a javascript framework for writing server-side applications)
NPM is now the 'GOTO' for all front-end javascript frameworks as well, including: React, Vue, Angular, Redux, GraphQL, Fabric UI, Babel, WebPack, Yeoman
There have been a number of attempts to de-throne NPM but NPM is king Twitter created Bower in 2014 and Facebook created Yarn in 2016, both have lost momentum
npm is written using node.js
Before you can use npm you must install node.js first.

Install node.js and npm

visit and download for Windows.
When you download node.js you automatically get npm installed as well.
This installs into the following folder:

C:\program Files\nodejs\ 

You will need to restart your computer.

Check that node and npm are installed.

Open a command prompt and type following.

node -v 
npm -v

If you do not see version numbers then these are not installed.
node - v14.15.5
npm - 6.14.11
To install newer versions of Node and NPM download the installer from and run it again.
link -

Check Installation

To check which packages are installed on the device, globally
You can use "-g" or "--g".

npm list -g 
npm list --g
npm list -g --depth = 0



npm install -g _ is the global install flag 
npm install -save _ means the package will appear in your dependencies
npm install -save-dev _ means the package will appear in your devDependencies
npm install -save-optional _ means the package will appear in your optionalDependencies

dependencies - these are modules required at runtime (--save)
devDependencies - these are modules only required during development (--save-dev)

npm install

If you project contains a "package.json" file this command will install all the dependencies.

npm install 

If you want to install a specific version, append the version number to the end.

npm install react@17.0.1 

If you want to install the latest version, append the word latest to the end.

npm install react@latest 

npm uninstall

This lets you uninstall a specific package.

npm uninstall office-ui-fabric-react --save 

--save: Package will be removed from your dependencies.
--save-dev: Package will be removed from your devDependencies.
If you want to uninstall a globally installed package.

npm uninstall -g office-ui-fabric-react 

npm update

This lets you update all the packages to their latest version.

npm update 

A new minor version (or patch version) can be specified with a caret.

^3.9.2 will update to 3.*.* 

A new patch version can be specified with a tilde.

~3.9.2 will update to 3.9.* 

npm outdated

This lets you discover new releases of the dependency packages.

npm outdated 

npm list

This will list all the packages that are installed globally

npm list -g --depth=0 


npm install --save-dev babel-preset-react ??? 
npm install --save-dev source-map-loader ???

npm cache clean --force 

Install Timeouts

npm ERR! network Socket timeout
npm ERR! network This is a problem related to network connectivity.

This means the command cannot succeed because npm fails to fetch some module due to internet connection problems.
You can try increasing the number of npm fetch timeouts that are allowed.

npm config set fetch-retry-maxtimeout 120000 

© 2023 Better Solutions Limited. All Rights Reserved. © 2023 Better Solutions Limited TopPrevNext