What is npm install -g npm

Hello

I am learning node and the node package manager. I understand the npm is to install libraries and packages etc. I understand node.js runtime is what will execute the javascript code but in the tutorial I am following it says to do this

npm install -g npm

This is installing the npm package according to the guide. What is the npm package?

Ive read these pages:
https://www.npmjs.com/
https://www.npmjs.com/package/npm

The first page gives common packages which people install, one of which is npm, a javascript package manager

I thought i had already installed the node package manager with node? Please can you explain the difference between the npm command line tool and the npm package you install with it?

Many thanks
Andrea EdwardsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David FavorLinux/LXD/WordPress/Hosting SavantCommented:
Decoding...

npm install -g npm

Open in new window


1) npm - script your running

2) install -g - says to install any packages globally, so anyone can use these packages + only root will be able to update these packages

3) package(s) - in your case you're installing the npm package

So this is likely a local npm installation used to install npm globally.

For this to work you'd have to likely add a sudo, like this...

sudo npm install -g npm

Open in new window


Normally the actual npm command is installed globally in a slightly different manner.

https://github.com/nodesource/distributions provides install instructions for both NodeJS + npm for various Distros.

Best to follow these instructions to install latest NodeJS + npm.
0
it_saigeDeveloperCommented:
If you are installing on a Windows machine, you do not need to use sudo, but you may have to launch an Administrative command prompt.

-saige-
0
Andrea EdwardsAuthor Commented:
Thank you for your detailed reply but I am still confused.

1) Is npm 2 things: both a package manager and a separate package you can install with the package manager too which would be very confusing

2)  Or is npm a package manager which you install 'somehow' then use that to install other packages? Is that general idea correct?

3) If 2) is correct  I can understand that the command I posted is some weird way of using a local install of npm to install it globally. Is that what you are saying (only you didnt say it was weird)?

4) if 2) and 3) are correct and I am on a windows machine, this is the way to install it https://github.com/nodesource/distributions?

Thanks
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

it_saigeDeveloperCommented:
1.  Node Package Manager (NPM), manages the packages that are required by node applications.  Since, by definition, npm is a package, npm can install/update itself (after it is initially installed); e.g. -
npm install npm@latest -g

Open in new window


2.  NPM is used primarily from a command-line interface (CLI) to install packages.  The complete list of CLI commands can be found on the npm website: https://docs.npmjs.com/

3.  It's not weird for applications update themselves, why should it be weird for npm to use the same process?

4.  To install NPM on a windows machine, you simply need to install Node.js (NPM is distributed with Node.js): https://docs.npmjs.com/getting-started/installing-node

-saige-
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Andrea EdwardsAuthor Commented:
Thank you for your answer. It is very clear and you are right it is not weird for something to update itself. Also, thank-you for addressing the questions individually as this greatly facilitates a dialogue.
0
Andrea EdwardsAuthor Commented:
Thank you for your clear explanation
0
it_saigeDeveloperCommented:
Glad I could be of assistance.

-saige-
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Node.js

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.