DEV Community

Manthan Ankolekar
Manthan Ankolekar

Posted on

1

Commonly used npm commands

Initializing a project

npm init
Enter fullscreen mode Exit fullscreen mode

Installing packages

npm install <package-name>      // Install package locally
npm install -g <package-name>   // Install package globally
npm install --save <package-name>    // Install package and save it as a dependency in package.json
npm install --save-dev <package-name> // Install package and save it as a development dependency in package.json
Enter fullscreen mode Exit fullscreen mode

Uninstalling packages

npm uninstall <package-name>    // Uninstall package locally
npm uninstall -g <package-name> // Uninstall package globally
Enter fullscreen mode Exit fullscreen mode

Running scripts defined in package.json

npm run <script-name>
Enter fullscreen mode Exit fullscreen mode

Updating packages

npm update                     // Update all packages
npm update <package-name>      // Update a specific package
Enter fullscreen mode Exit fullscreen mode

Listing installed packages

npm ls                         // List installed packages
npm ls -g                      // List globally installed packages
Enter fullscreen mode Exit fullscreen mode

Searching for packages

npm search <keyword>           // Search for packages in the npm registry
Enter fullscreen mode Exit fullscreen mode

Viewing package information

npm view <package-name>        // View details about a package
npm view <package-name> versions    // View available versions of a package
Enter fullscreen mode Exit fullscreen mode

Publishing packages

npm publish                    // Publish a package to the npm registry
Enter fullscreen mode Exit fullscreen mode

Managing package versions

npm version <new-version>          // Update the version of your package
Enter fullscreen mode Exit fullscreen mode

Installing packages from a package.json file

npm install                // Install packages listed in package.json
Enter fullscreen mode Exit fullscreen mode

Cleaning the npm cache

npm cache clean            // Clear the entire npm cache
Enter fullscreen mode Exit fullscreen mode

Heroku

Built for developers, by developers.

Whether you're building a simple prototype or a business-critical product, Heroku's fully-managed platform gives you the simplest path to delivering apps quickly — using the tools and languages you already love!

Learn More

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

DEV works best when you're signed in—unlocking a more customized experience with features like dark mode and personalized reading settings!

Okay