Skip to content
This repository has been archived by the owner on Apr 7, 2021. It is now read-only.

[QUESTION] How do I update a package in the cache? #93

Closed
leafac opened this issue Jan 12, 2021 · 10 comments
Closed

[QUESTION] How do I update a package in the cache? #93

leafac opened this issue Jan 12, 2021 · 10 comments

Comments

@leafac
Copy link

leafac commented Jan 12, 2021

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
@ljharb
Copy link

ljharb commented Jan 12, 2021

It should automatically use the new version, unless it’s installed locally or globally.

@leafac
Copy link
Author

leafac commented Jan 12, 2021

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?

@ljharb
Copy link

ljharb commented Jan 12, 2021

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?

@leafac
Copy link
Author

leafac commented Jan 12, 2021

$ 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…

leafac added a commit to leafac/obs-cli that referenced this issue Jan 12, 2021
@leafac
Copy link
Author

leafac commented Jan 12, 2021

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…

@ljharb
Copy link

ljharb commented Jan 12, 2021

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?

@leafac
Copy link
Author

leafac commented Jan 20, 2021

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

@leafac
Copy link
Author

leafac commented Jan 24, 2021

@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?

@ljharb
Copy link

ljharb commented Jan 24, 2021

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).

@leafac
Copy link
Author

leafac commented Jan 26, 2021

Okay. Thank you for your help.

I’m closing this in favor of npm/cli#2329

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants