From cb255c70f829cae906a2e51b78f15be9e5cc6d68 Mon Sep 17 00:00:00 2001 From: Leonardo-Garzon-1995 Date: Mon, 10 Nov 2025 15:45:59 +0100 Subject: [PATCH] feat: npm ceatsheet --- source/_posts/npm.md | 73 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 72 insertions(+), 1 deletion(-) diff --git a/source/_posts/npm.md b/source/_posts/npm.md index d639006..cf511a0 100644 --- a/source/_posts/npm.md +++ b/source/_posts/npm.md @@ -76,7 +76,7 @@ npm rm # Shorthand for uninstall ```bash npm view # View package details npm view versions # View all versions of a package -npm view version # View the latest version of a package +npm view version # View the latest version of a package npm view description # View the description of a package ``` @@ -93,3 +93,74 @@ npm docs # Open package documentation in the brows npm home # Open package homepage in the browser npm repo # Open package repository in the browser ``` + +## Managing packages + +### Updating packages + +```bash +npm outdated # Check for outdated packages +npm update # Update a specific package +npm update # Update all packages +``` + +### Listing installed packages + +```bash +npm list # List installed packages in the current project +npm list -g # List globally installed packages +npm list --depth=0 # List top-level installed packages only +``` + +### Running scripts + +```bash +npm run # Run a script defined in package.json +npm start # Run the 'start' script +npm test # Run the 'test' script +npm build # Run the 'build' script +``` + +### Cache management + +```bash +npm cache verify # Verify the integrity of the npm cache +npm cache clean # Clear the npm cache +npm cache clean --force # Force clear the npm cache +``` + +### Configuring npm + +```bash +npm config list # List all npm configuration settings +npm config set # Set a configuration value +npm config get # Get the value of a configuration key +npm config delete # Delete a configuration key +``` + +### Auditing and security + +```bash +npm audit # Audit dependencies for vulnerabilities +npm audit fix # Fix vulnerabilities in dependencies +npm audit fix --force # Force fix vulnerabilities, may update major versions +``` + +## Publishing packages + +```bash +npm login # Log in to your npm account (npmjs.com) +npm publish # Publish a package to the npm registry +npm version # Bump the version of your package (e.g., patch, minor, major) +npm unpublish # Unpublish a package (within 72 hours of publishing) +``` + +## Other useful commands + +```bash +npm help # Get general help on npm +npm help # Get help on a specific npm command +npm ci # Install dependencies from package-lock.json (clean install) +npm prune # Remove extraneous packages +npm dedupe # Reduce duplication in the node_modules folder +```