Pacharapol Withayasakpunt Pacharapol Withayasakpunt
Wed, April 15, 2020

Avoiding having both `yarn.lock` and `package-lock.json`

This is possible with pre-install script to check for yarn.lock and package.json.

The closest I can find for this is,

https://github.com/sindresorhus/is-npm

Now, I did ask the author to make CLI for me, but he didn't do exactly what I needed, so I made one myself.

https://github.com/patarapolw/check-npm-yarn

Now, there is still an extra step. "preinstall": "npx check-npm-yarn" alone might not be enough. To avoid npx and installing every time, I make it,

{
  "scripts": {
    "preinstall": "if command -v check-npm-yarn > /dev/null; then check-npm-yarn; fi"
  }
}

An issue with NPM -- preinstall npm hook doesn’t execute when installing a specific package

I created nsi script for this.

nsi packageA packageB packageC ...
// Or nsi packageA packageB packageC ... --dev

Related Topic

https://dev.to/patarapolw/do-you-have-a-strong-reason-to-use-npm-or-yarn-or-something-else-3pbm

Tags: node.js