nodejs / corepack

Zero-runtime-dependency package acting as bridge between Node projects and their package managers
MIT License
2.31k stars 146 forks source link

fix: add path to `package.json` in error message #456

Closed aduh95 closed 2 months ago

aduh95 commented 2 months ago

I had to help someone who couldn't understand why they were getting this error message on an empty directory; turned out they had a package.json in their home directory (no idea how it got there) that defined a packageManager field. I think adding some explanation would help.

arcanis commented 2 months ago

no idea how it got there

That's an issue we sometimes have with yarnPath as well. Perhaps we should make corepack use fail if run in the home directory, unless a special CLI flag is set (like rm --no-preserve-root)?