Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npx rimraf -g ./**/dist ./**/node_modules first run seems to succeed but always gives "The system cannot find the path specified." and "WARN Local package.json exists, but node_modules missing, did you mean to install?" #304

Closed
JasonKleban opened this issue May 1, 2024 · 5 comments

Comments

@JasonKleban
Copy link

npx rimraf -g ./**/dist ./**/node_modules first run seems to succeed but always gives "The system cannot find the path specified." and "WARN Local package.json exists, but node_modules missing, did you mean to install?"

Second run doesn't emit those messages. I tried breaking that pattern into two in both orders, but no effective change.

Is it because of chains of symlinks between various nested dist & node_module folders? Is there a way to deal with this more elegantly without hurting complexity, performance, or platform agnosticism?

@isaacs
Copy link
Owner

isaacs commented May 10, 2024

It looks like npx is trying to use your locally-installed version of rimraf. But then you're using rimraf to delete itself.

Maybe you mean this? npx rimraf -g '*/**/dist' '*/**/node_modules' That would prevent removal of ./node_modules/rimraf or ./node_modules/rimraf/dist.

@isaacs
Copy link
Owner

isaacs commented May 10, 2024

(The relevant difference is the */ to make it only start searching one level down, not in the root itself, since ** can match the empty string.)

@JasonKleban
Copy link
Author

Definitely relevant, thanks! The fact that it was succeeding anyway was throwing me off, but yeah, I do want to nuke everything. Using npx rimraf@latest -g ./**/dist ./**/node_modules @latest make sure to use the remote package instead of some random locally available one.

@isaacs
Copy link
Owner

isaacs commented May 13, 2024

Ah, yes, that's another way to ensure npm runs the rimraf from an external location. Still a bit risky, since it means you have an effective dependency on *, but rimraf is about as stable a library as one could hope for, at least in the bin interface.

@JasonKleban
Copy link
Author

Ripe for a supply chain attack!

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

No branches or pull requests

2 participants