Created
October 28, 2022 07:37
-
-
Save akshayjai1/4326c1a2b4b625186527138ac0e5f046 to your computer and use it in GitHub Desktop.
A script that can be added to run before npm start or any other script to enforce a particular npm version
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { exec } = require('child_process'); | |
exec('npm -v', (err, stdout) => { | |
if (err) throw err; | |
if (parseInt(stdout) !== 8) { | |
// 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 @8 but you have ${stdout}`); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment