nodejs / corepack

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

`corepack use` fails with ENOENT: no such file or directory, open '/app/package.json' #347

Closed styfle closed 7 months ago

styfle commented 8 months ago

When a package.json file is missing, corepack use fails with ENOENT.

I think it would be great if corepack could create the package.json file when its missing.

It would avoid the need to call npm init -y, yarn init -y, or pnpm init in some cases.

aduh95 commented 8 months ago

What do you think should be the behavior? Should Corepack call <pkg-manager> init in such case? Or just create a package.json with only the "packageManager" field?

styfle commented 8 months ago

The second option - create package.json directly with one field.

Interesting idea to call init though. Seems like that could be implemented under a different sub command however. Keep “use” simple.

styfle commented 7 months ago

@aduh95 Thanks for the quick fix! 🎉