Skip to content

Instantly share code, notes, and snippets.

@silver-xu
Last active December 18, 2021 12:26
Show Gist options
  • Save silver-xu/5e81a7df34cd7d3ca3f46b83b16a0cbb to your computer and use it in GitHub Desktop.
Save silver-xu/5e81a7df34cd7d3ca3f46b83b16a0cbb to your computer and use it in GitHub Desktop.

Enforcing the use of Yarn or NPM in a team

Leading a software development team and sick of telling everyone to yarn install instead of npm install everytime? Annoyed by someone checking in package-lock.json? All these issue could have been avoided by using one-package-manager.

One-package-manager is an un-opinionated script for Javascript Projects to help enforcing the use of Yarn or NPM consistently within a software development team that requires no installation and minimal configuration.

To enable one-package-manager, simply adding the following to your package.json:

{
  "scripts":{
    "preinstall": "npx one-package-manager --yarn"
  }
}

Change the --yarn to --npm to set the enforced Package Manager to NPM.

Try it out by typing

npm install

One-package-manager will stop the npm install from executing and display an error message:

image

At the end

Feel free to fork: https://github.com/silver-xu/one-package-manager

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment