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

Docs: Mention "packageManager" field on NodeJS docs #2270

Open
Leksat opened this issue Sep 13, 2024 · 3 comments
Open

Docs: Mention "packageManager" field on NodeJS docs #2270

Leksat opened this issue Sep 13, 2024 · 3 comments
Labels
feature New feature or request triage Issue needs triage

Comments

@Leksat
Copy link

Leksat commented Sep 13, 2024

What problem are you trying to solve?

https://www.jetify.com/devbox/docs/devbox_examples/languages/nodejs/ suggests using DEVBOX_COREPACK_ENABLED to get a desired package manager. Also, at the bottom of the page there is another example:

  "packages": [
    "nodejs@18",
    "nodePackages.yalc@latest",
    "nodePackages.pm2@latest"
  ]

Reading this page, I created my devbox.json as follows:

  "packages": [
    "nodejs@18.19.0",
    "nodePackages.pnpm@8.6.12" // oh no...
  ],

And was quite confused to see this behavior:

$ node -v
v18.19.0

$ pnpm -v
8.6.12

$ pnpm i
Your Node version is incompatible with the project.
Expected version: ^18.19.0
Got: v18.17.1

I have found what I was doing wrong after reading some source code. (No idea how I got there 😅)

"readme": "Devbox automatically configures Corepack for Nodejs when DEVBOX_COREPACK_ENABLED=1. You can install Yarn or Pnpm by adding them to your `package.json` file using `packageManager`\nCorepack binaries will be installed in your local `.devbox` directory",

You can install Yarn or Pnpm by adding them to your package.json file using packageManager

What solution would you like?

I know there are links to example repos on the docs page. But it would make it much easier to follow if "packageManager" field is mentioned directly on the docs page 🙏

Alternatives you've considered

Close this issue and let the newcomers struggle 😁

@Leksat Leksat added feature New feature or request triage Issue needs triage labels Sep 13, 2024
@Leksat
Copy link
Author

Leksat commented Sep 13, 2024

Also, it was a surprise that nodePackages.pnpm came with its own Node.js. I was expecting it to use nodejs I defined in packages. Are there any docs about this?

@savil
Copy link
Collaborator

savil commented Sep 13, 2024

Would it help to add a callout-visual element that says Use Corepack to install yarn or pnpm. Enabling Corepack will introduce the yarn and pnpm binaries into your shell environment that work with your version of nodejs specified via devbox add. ?

Also, it was a surprise that nodePackages.pnpm came with its own Node.js.

Yes, this is because Devbox relies on Nix packages, which are designed to be reproducibly installed and run. To achieve this, each nix package specifies the specific versions of their dependencies. When nodePackages.pnpm@latest is installed it will install the specific version of nodejs that this latest version was defined as depending on.

@Leksat
Copy link
Author

Leksat commented Sep 13, 2024

For me, the text that I have found in the code would work better, maybe a little rephrased:

You can install Yarn or Pnpm by adding them to the packageManager field of your package.json.

And maybe an addition:

See the example repositories below.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request triage Issue needs triage
Development

No branches or pull requests

2 participants