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

`npx use-yarn` fails on node 16 #15

Closed bencooper222 closed 2 years ago

bencooper222 commented 2 years ago

Node version: 16.13.0 Npm version: 8.1.0 use-yarn version: using via npx so latest

npx use-yarn now throws an error, probably because the behavior of npx was changed such that it looks like npm to whatever detection method your package uses.

AndersDJohnson commented 2 years ago

@bencooper222 Good find. Do you think we should just remove the documentation around npx use-yarn? Have you tried using "use-yarn || ( npm install --save-dev --no-scripts --no-save use-yarn && use-yarn )" from the docs - does that still work?

MaSpeng commented 2 years ago

@AndersDJohnson For me, the mentioned command "use-yarn || ( npm install --save-dev --no-scripts --no-save use-yarn && use-yarn )" leads to an infinite loop /bin/sh: use-yarn: not found.

AndersDJohnson commented 2 years ago

@MaSpeng Interesting, is the npm install not working for you there? I thought that was a valid bash command.

MaSpeng commented 2 years ago

@AndersDJohnson at least for me it's not working in the yarn context. When I use it directly in the shell it works as expected.

AndersDJohnson commented 2 years ago

@bencooper222 @MaSpeng OK so with PR https://github.com/AndersDJohnson/use-yarn/pull/16 and some additional changes like https://github.com/AndersDJohnson/use-yarn/commit/cbec3f35ae723a96d615d31178052a2499b754fa, etc., I think I have npx support working now published in version 2.4.0. If you want to confirm your version, you can use new npx use-yarn -v option. You do need to update your usage in preinstall to pass $npm_execpath as follows:

-  "preinstall": "npx use-yarn"
+  "preinstall": "npx use-yarn $npm_execpath"

Please let me know if it works!

MaSpeng commented 2 years ago

@AndersDJohnson Works 👍