Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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,868 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,868 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