DEV Community

Cover image for Recalling NPM Commands to Your Heart's Content
S.M. Faizul Islam Fair
S.M. Faizul Islam Fair

Posted on • Edited on

Recalling NPM Commands to Your Heart's Content

Who doesn't love a decent package for development purposes? These packages come of so many usual and unusual variations just to match with your desired requirements. And to keep you running them we got just what you need! Enjoy the show fellow devs:

NPM Commands

Image description

npm version checking

npm -v
Enter fullscreen mode Exit fullscreen mode

To find out usages of npm

npm help
Enter fullscreen mode Exit fullscreen mode

To find out ways of installing individual npm files

npm install -h
Enter fullscreen mode Exit fullscreen mode

To create package.json file

npm init
Enter fullscreen mode Exit fullscreen mode

To create package.json file without typing out anything else

npm init --yes
Enter fullscreen mode Exit fullscreen mode

or,

npm init -y
Enter fullscreen mode Exit fullscreen mode

To set package.json defaults

npm config set init-author-name "name"
Enter fullscreen mode Exit fullscreen mode

or,

npm set init-license "name"
Enter fullscreen mode Exit fullscreen mode

To install a specific package

npm install "package_name"
Enter fullscreen mode Exit fullscreen mode

or,

npm i "package_name"
Enter fullscreen mode Exit fullscreen mode

To install a specific package just for development and not for production

npm install "package_name" --save-dev
Enter fullscreen mode Exit fullscreen mode

or,

npm i "package_name" -D
Enter fullscreen mode Exit fullscreen mode

To uninstall a package

npm uninstall "name"
Enter fullscreen mode Exit fullscreen mode

To install a package globally

npm install "package_name" -g
Enter fullscreen mode Exit fullscreen mode

To uninstall a package globally

npm uninstall "package_name" -g
Enter fullscreen mode Exit fullscreen mode

To list down installed packages

npm list
Enter fullscreen mode Exit fullscreen mode

To install a specific version of package

npm install "package_name@version"
Enter fullscreen mode Exit fullscreen mode
For Example - 3.4.1, here 3 is major version, 4 is minor version and 1 is patch version number
Enter fullscreen mode Exit fullscreen mode

To update a specific package

npm install "package_name@latest"
Enter fullscreen mode Exit fullscreen mode

To remove any packages not listed in package.json

npm prune
Enter fullscreen mode Exit fullscreen mode

Top comments (0)