Skip to content

Instantly share code, notes, and snippets.

@nireno
Created June 25, 2019 01:58
Show Gist options
  • Save nireno/52b3ee8b55e0ab9a7448375f0af1ac38 to your computer and use it in GitHub Desktop.
Save nireno/52b3ee8b55e0ab9a7448375f0af1ac38 to your computer and use it in GitHub Desktop.
Generate a script that would upgrade all npm dependencies to @latest
const { execSync } = require('child_process');
let stdout = execSync('npm ls --json=true --depth=0');
let packageJson = JSON.parse(stdout);
let packages = Object.keys(packageJson.dependencies);
let packagesString = packages
.map(package => `${package}@latest`)
.join(' ');
console.log(`npm install ${packagesString}`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment