Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript npm Basics (retiring) Updating and Uninstalling Packages with npm Updating Global Packages with npm

Martina Carrington
Martina Carrington
15,754 Points

Challenge Task 1 of 1 Update the global package npm.

i try npm install update -g and npm install - g i keep getting error

3 Answers

William Li
PLUS
William Li
Courses Plus Student 26,858 Points

Hi, Martina, the correct command is

npm update -g npm

Update the global package npm.

It may come as surprise, but npm itself is a global package, and you can use npm to update npm.

Martina Carrington
Martina Carrington
15,754 Points

wait so it's not npm install update - g ? how come we have to add a extra npm at end ? Thanks @William Li

William Li
William Li
Courses Plus Student 26,858 Points

how come we have to add a extra npm at end ?

As I've previously said, npm itself is a global package, and the syntax for updating global package is.

npm update -g <package name>

# example
npm update -g express

As to why we need to update npm? Because that's what the code challenge is asking for Update the global package npm.

You can also do a global update using a similar but different format:

npm update <package> -g

im still getting an error massage even if i copy and paste this code

Martina Carrington
Martina Carrington
15,754 Points

oh ok ! now i got it , Thanks so William Li