Skip to content

Conversation

@aurelien-reeves-scalingo
Copy link
Contributor

@aurelien-reeves-scalingo aurelien-reeves-scalingo commented Sep 3, 2025

Documentation regarding node.js devDependencies pruning is wrong.
I did some tests to make sure of actual behavior: it leads into the following:

npm/yarn env var cache install dev deps pruned
npm none none yes yes
npm none yes yes yes
npm NPM_CONFIG_PRODUCTION none no skipped
npm NPM_CONFIG_PRODUCTION yes no Skipped
yarn none none yes yes
yarn none yes yes yes
yarn YARN_PRODUCTION no no skipped
yarn YARN_PRODUCTION yes no skipped
yarn 2+ none no yes yes
yarn 2+ none yes yes yes
yarn 2+ YARN2_SKIP_PRUNING no yes skipped
yarn 2+ YARN2_SKIP_PRUNING yes yes skipped

It appears that, at the moment, the only way to keep dev dependencies as part of the image is to use yarn v2+ with YARN2_SKIP_PRUNING

@aurelien-reeves-scalingo aurelien-reeves-scalingo marked this pull request as ready for review September 3, 2025 09:42
Copy link
Contributor

@Frzk Frzk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

praise: thanks a lot for trying to clarify this. It's been a subject for a long time.

I've added a few suggestions, which are mostly nitpicks.

I'm wondering if this is the behavior we really want 🤔
@EtienneM: WDYT?

Maybe we could also add your table @aurelien-reeves-scalingo? It would make things crystal-clear, wouldn't it?

Finally, we also have a PR here, waiting for approval. I don't think it would have consequences on yours, but could please double-check? 🙏

Thanks a lot <3

@aurelien-reeves-scalingo
Copy link
Contributor Author

Finally, we also have a PR Scalingo/nodejs-buildpack#176, waiting for approval. I don't think it would have consequences on yours, but could please double-check? 🙏

Thanks for pointing me out to that PR.

It makes me realized that I don't understand how the yarn pruning is working. My tests tend to show that the pruning of dependencies with yarn is working as expected, but from reading the code (on master), I have no idea how it actually works.

In the end, there is no consequences, no impact from one PR to another, that's for sure.

Copy link
Member

@EtienneM EtienneM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the "cache" column in your table.

Otherwise I agree with François that the table could be a good addition to our documentation to clarify how the buildpack behave with Yarn v1, Yarn v2 and npm.

Then you can use this CLI command pattern: `scalingo --app my-app env-set variable=value`

Example for npm : `scalingo --app my-app env-set NPM_CONFIG_PRODUCTION=true`
If you need access to packages declared under `devDependencies` at runtime - or in a different buildpack - then you'll need to use yarn v2+ and set `YARN2_SKIP_PRUNING=true`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not keen on this change. I don't think we want to force customers to use Yarn if they need to access dependencies declared in devDependencies.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no other alternative right now

most common error messages.

## devDependencies Also Contain the Build Dependencies {#dep}
## devDependencies Also Contain Some Dependencies Required at Startup or Runtime {#dep}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this section should highlight the type of errors a customer may face, and link to languages/nodejs/2000-01-01-start#devdependencies-installation to explain how to circumvent them.

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

Successfully merging this pull request may close these issues.

4 participants