How can I know when to prompt user to run npm install if there are any unmet package.json dependencies?
I would like to do this, because if any re
Another solution
function dependenciesNeedUpdating() {
const childProcess = require('child_process');
const result = JSON.parse(childProcess.execSync('npm install --dry-run --json').toString());
return result.added.length > 0 || result.updated.length > 0 || result.removed > 0;
}
Call it like this
if (dependenciesNeedUpdating()) {
console.error('dependencies need updating. Please run `npm install`');
process.exit(1);
}
If you want to install this as a dependency