[QUESTION] How do I update a package in the cache?
leafac opened this issue · comments
What / Why
If I don’t have obs-cli installed and run npx obs-cli --version
, then npx installs obs-cli. When a new version of obs-cli is released, how do I update it on my machine such that npx obs-cli --version
shows me latest version?
So far my workaround has been to rm -rf ~/.npm
. I’m sure there must be a less heavy-handed way of doing this, but I couldn’t find anything online.
Where
- n/a
Who
@isaacs (I assume, because of his activity here)
References
- n/a
It should automatically use the new version, unless it’s installed locally or globally.
Do consider the first run of npx obs-cli
a global install? It isn’t listed by npm ls -g
, so I thought of it as only being install in the npm cache, if such a thing makes sense. In any case, I never ran anything to the effect of npm install obs-cli
(-g
or not), and I have the problem described above of having to remove ~/.npm
.
Can you please clarify what’s going on?
No, only npm install -g is a global install.
what version of npm/npx are you having this problem with? Are you using the npx that came with npm, or did you update it separately?
$ npx --version
7.4.0
$ node --version
v15.2.0
$ npm --version
7.4.0
I update npm when it asks me, but I never updated npx by itself.
UPDATE: I’m running brew upgrade
here to see if that’ll help…
No dice:
$ node --version
v15.5.1
$ npm --version
7.4.0
$ npx --version
7.4.0
$ npx obs-cli --version
2.0.0
I released a dummy 2.0.1 version of obs-cli to test this out. It isn’t picked up by npx…
When I run npx obs-cli --version
, I don't see anything in ~/.npm
for obs-cli
. What happens with which obs-cli
, and npm ls -g --depth=0 | grep obs
?
Oops, I missed your answer here, sorry.
$ which obs-cli
obs-cli not found
$ npm ls -g
/usr/local/lib
└── npm@7.4.0
That makes sense, since the point of using npx
was to never have to npm install --global
, so obs-cli
isn’t on the PATH
.
I’m confident npx
is installing things on the npm
cache at ~/.npm
:
$ find ~/.npm | grep obs-cli
/Users/leafac/.npm/_npx/58ae1233f0a6b735/node_modules/.bin/obs-cli
/Users/leafac/.npm/_npx/58ae1233f0a6b735/node_modules/obs-cli
/Users/leafac/.npm/_npx/58ae1233f0a6b735/node_modules/obs-cli/CODE_OF_CONDUCT.md
/Users/leafac/.npm/_npx/58ae1233f0a6b735/node_modules/obs-cli/LICENSE
/Users/leafac/.npm/_npx/58ae1233f0a6b735/node_modules/obs-cli/index.js
/Users/leafac/.npm/_npx/58ae1233f0a6b735/node_modules/obs-cli/README.md
/Users/leafac/.npm/_npx/58ae1233f0a6b735/node_modules/obs-cli/package.json
/Users/leafac/.npm/_npx/58ae1233f0a6b735/node_modules/obs-cli/.github
/Users/leafac/.npm/_npx/58ae1233f0a6b735/node_modules/obs-cli/.github/workflows
/Users/leafac/.npm/_npx/58ae1233f0a6b735/node_modules/obs-cli/.github/workflows/main.yml
@ljharb: Judging by the 👍 on my previous comment it seems like you agree that npx
installs packages in the npm
cache at ~/.npm
. Do you know how I can tell npx
to update a package that’s in there without having to resort to rm -rf ~/.npm
?
I don’t. It seems like it might be a bug, though. I’d suggest trying npx on npm 7 latest, and then if it’s still not working, file a bug on the cli repo (since that’s where npm 7’s npx lives).
Okay. Thank you for your help.
I’m closing this in favor of npm/cli#2329