๐ป๐ป A first step to becoming an npm virtuoso
Benjamin Mock
ใป2 min read
The obvious
visit npmjs.com to find modules. Use bundlephobia to get size information of the packages.
Use npmtrends or npmcharts to compare the popularity of packages.
installing a package
npm i express
installing a package as dev dependency
npm i --save-dev express
or
npm i -D express
installing a package globally
npm i express -g
removing a package
npm uninstall express
(add -g
to install / uninstall globally)
The not so obvious
get outdated packages
npm outdated
show all installed packages
npm list
(ls
, la
and ll
can be used as aliases for list
)
show all globally installed packages
npm list --global
you should probably use it like this, otherwise the output will be quite long, because this also shows the dependencies of your globally installed packages.
npm list --global --depth=0
visit the package page on npmjs.com
npm home <package>
Getting information about packages
show which version is used and which packages are requiring the specified module
npm ls express
show all available versions, description, contributers of a package
npm view express
Local Development with packages aka Linking
in my-module (will later on be used in the host project)
npm link
in the host project (which is going to use my-module)
npm link my-module
If you link a package, it'll be automatically updated in the target application
or just install the local module via the file system
npm install ../my-module
show all globally linked modules
npm ls -g --depth=0 --link=true
Creating a local package
npm init
or
npm init -y
to answer all the questions during the installation process with yes.
Do you have some useful npm commands, that you are using on a regular basis? Or some lifesavers? Please add them in the comments!
Thanks for reading!