npmcheckversion.js 333 Bytes
Newer Older
Julien Benchetrit's avatar
Julien Benchetrit committed
1 2 3 4 5 6 7 8
const { exec } = require('child_process');
exec('npm -v', (err, stdout) => {
  if (err) throw err;
  if (parseFloat(stdout) < 5) {
    // NOTE: This can happen if you have a dependency which lists an old version of npm in its own dependencies.
    throw new Error(`[ERROR] You need npm version @>=5 but you have ${stdout}`);
  }
});