Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Preview
Start a free Courses trial
to watch this video
In this video, we'll remove packages that are no longer needed.
Terminal Commands
- Clear the screen
clear
npm Command Line Usage
-
See list of commands
npm
-
Uninstalling packages
- Uninstall a local dependency:
npm uninstall <package name>
- e.g.
npm uninstall colors
- e.g.
- Uninstall a local dependency and remove from
package.json
:npm uninstall <package name> --save
- e.g.
npm uninstall colors --save
- e.g.
- Uninstall a local development dependency and remove from
package.json
:npm uninstall <package name> --save-dev
- e.g.
npm uninstall mocha --save-dev
- e.g.
- Uninstall a global dependency:
npm uninstall <package name> -g
- e.g.
npm uninstall http-server -g
- e.g.
- Uninstall a local dependency:
Further Reading
We've installed packages and
updated packages.
0:00
The next natural step would
be to uninstall them.
0:04
Let's say I wanted to uninstall
the colors package from my project.
0:07
We'd use NPMs uninstall command,
followed by their package name.
0:11
This removes or deletes the colors
folder from the nodes module folder.
0:18
However if I type in NPM install again,
it'll reinstall the colors.
0:23
Because the package is listed
in the package.json file,
0:28
it's installed every time
we type in NPM install.
0:32
To remove it permanently or
at least until we actually want it to be
0:36
a dependency again,
we can use the dash dash save flag.
0:40
Note that now, not only is it removed
from the node_modules folder,
0:47
it's also removed from
the package.json file.
0:52
If you want to get rid of
a development dependency,
0:56
you can do NPM, uninstall, the name of
1:03
the module you want to uninstall and
then --save dev.
1:08
Finally, to uninstall a global package,
1:18
you type in NPM uninstall
then the package name.
1:24
And the -g flag.
1:33
I am going to uninstall my http
server utility from my local machine.
1:36
And if I spelt uninstall correctly,
you won't get this.
1:45
Oh it's gone.
1:50
We've gone over the most common use
cases of NPM in your day to day life.
1:52
We've searched for packages, installed,
updated and uninstalled packages.
1:58
But when you type in NPM,
a lot of commands are shown.
2:03
I encourage you to take your time and
2:06
take a look at some of these
that look interesting to you,
2:10
and use the help command to explore
the things that NPM has to offer.
2:16
You can also go to the documentation
site https://docs.npmjs.com,
2:23
which is an awesome
resource if you get stuck.
2:31
It's also a great place to
learn even more about NPM.
2:35
There you have it, NPM.
2:40
By now you should be able to maintain
your dependencies in your own Java script
2:41
projects.
2:45
You also know how to
install global utilities.
2:46
If you still have burning questions
on NPM, try the faq command.
2:49
If you need more, jump in the forum and
ask your question there.
2:54
With these new NPM skills under your belt,
the sky's the limit for
2:57
the types of projects you
can build in JavaScript.
3:00
You need to sign up for Treehouse in order to download course files.
Sign up