AndersDJohnson / use-yarn

Force users to use yarn instead of npm.
https://andersdjohnson.github.io/use-yarn/
ISC License
50 stars 12 forks source link

Forbid to add packages with npm #12

Closed InsOpDe closed 4 years ago

InsOpDe commented 4 years ago

After adding

        "preinstall": "npx use-yarn",

to my scripts I still am able to add packages with npm like so

npm install lodash

it then proceeds to install everything like normal and adds the infamous package-lock.json

echo "$(node -v) $(yarn -v) $(npm -v)"
v13.13.0 1.22.4 6.14.5
AndersDJohnson commented 4 years ago

@InsOpDe Hey, thanks for using this package! I would love if we could support this feature, but from what I've read it may not be possible due to how npm install <pkg> is designed. https://npm.community/t/preinstall-npm-hook-doesnt-execute-when-installing-a-specific-package/2505

Let me know if you are aware of any solution and I can reconsider!

AndersDJohnson commented 4 years ago

@InsOpDe Maybe if you were running some kind of npm proxy for yourself or your organization, it could be possible to inject or modify preinstall scripts in each package dynamically on your proxy server? Probably not worthwhile.

InsOpDe commented 4 years ago

@InsOpDe Hey, thanks for using this package! I would love if we could support this feature, but from what I've read it may not be possible due to how npm install <pkg> is designed. https://npm.community/t/preinstall-npm-hook-doesnt-execute-when-installing-a-specific-package/2505

Let me know if you are aware of any solution and I can reconsider!

I didnt knew this - what a pity. Will still use the package! :) Will report back if I find another solution