From 2bde28dcd75c46de364e1cf01062758d90ce8238 Mon Sep 17 00:00:00 2001 From: aurelien-reeves-scalingo Date: Wed, 3 Sep 2025 11:38:11 +0200 Subject: [PATCH 1/3] fix(node.js) Update documentation related to devDependencies pruning --- .../nodejs/2000-01-01-deployment-errors.md | 16 ++++++++-------- src/_posts/languages/nodejs/2000-01-01-start.md | 15 ++------------- 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/src/_posts/languages/nodejs/2000-01-01-deployment-errors.md b/src/_posts/languages/nodejs/2000-01-01-deployment-errors.md index 1de6d6b93..9176d8502 100644 --- a/src/_posts/languages/nodejs/2000-01-01-deployment-errors.md +++ b/src/_posts/languages/nodejs/2000-01-01-deployment-errors.md @@ -10,21 +10,21 @@ You may experience an error in your Node.js application that many customers faced when first deploying such application on Scalingo. Here is a list of the most common error messages. -## devDependencies Also Contain the Build Dependencies {#dep} +## devDependencies Also Contain some Dependencies required at startup or runtime {#dep} -The `devDependencies` section of the package.json file contains both development -dependencies and build dependencies. By default Scalingo deployments install the -dependencies from the `dependencies` section of the package.json file. It may +The `devDependencies` section of the package.json file contains dependencies required +durint startup of the app, or during runtime. By default Scalingo deployments prune the +dependencies from the `devDependencies` section of the package.json file. It may lead to error messages such as `ng: not found` or `nest: not found`. In such situation, you have a couple of solutions: -- Install all `devDependencies` ([doc]({% post_url - languages/nodejs/2000-01-01-start %}#install-devdependencies)). +- Use yarn v2+ and skip pruning dependencies ([doc]({% post_url + languages/nodejs/2000-01-01-start %}#devdependencies-installation)). ```bash - $ scalingo --app my-app env-set NPM_CONFIG_PRODUCTION=false + $ scalingo --app my-app env-set YARN2_SKIP_PRUNING=true ``` -- Move the `devDependencies` needed for the build into the `dependencies` +- Move the `devDependencies` needed for runtime into the `dependencies` section of the package.json file. ## Boot Timeout {#timeout} diff --git a/src/_posts/languages/nodejs/2000-01-01-start.md b/src/_posts/languages/nodejs/2000-01-01-start.md index e6e432993..135d6bf4d 100644 --- a/src/_posts/languages/nodejs/2000-01-01-start.md +++ b/src/_posts/languages/nodejs/2000-01-01-start.md @@ -96,22 +96,11 @@ environment. By default, dependencies present in the `devDependencies` field are installed. At the end of the deployment, `devDependencies` are pruned. Hence only production dependencies are left in the image used for the runtime. -The pruning step can be skipped by setting the environment variable `YARN_PRODUCTION` to any value. +`devDependencies` can be totally ignored and not installed at all by setting `NPM_CONFIG_PRODUCTION=true` npm or `YARN_PRODUCTION=true` with yarn v1. #### Skip Pruning -If you need access to packages declared under devDependencies at runtime or in a different buildpack then, depending on the package manager used, you can set one of the following environment variables to skip the pruning step: - -| Package manager | Version | Environment variable | Value | -|-----------------|---------|-------------------------|---------| -| npm | Any | `NPM_CONFIG_PRODUCTION` | `true` | -| yarn | v1 | `YARN_PRODUCTION` | `true` | -| yarn | v2+ | `YARN2_SKIP_PRUNING` | `true` | - - -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`. ### Ensure you're Tracking all your Dependencies From d7db0a54c03951b1cc81f414d2e5e9cfd354999c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Reeves?= <111763415+aurelien-reeves-scalingo@users.noreply.github.com> Date: Thu, 11 Sep 2025 09:22:51 +0200 Subject: [PATCH 2/3] Update src/_posts/languages/nodejs/2000-01-01-deployment-errors.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: François --- src/_posts/languages/nodejs/2000-01-01-deployment-errors.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_posts/languages/nodejs/2000-01-01-deployment-errors.md b/src/_posts/languages/nodejs/2000-01-01-deployment-errors.md index 9176d8502..8dc395e1e 100644 --- a/src/_posts/languages/nodejs/2000-01-01-deployment-errors.md +++ b/src/_posts/languages/nodejs/2000-01-01-deployment-errors.md @@ -13,7 +13,7 @@ most common error messages. ## devDependencies Also Contain some Dependencies required at startup or runtime {#dep} The `devDependencies` section of the package.json file contains dependencies required -durint startup of the app, or during runtime. By default Scalingo deployments prune the +during startup of the app, or during runtime. By default, Scalingo deployments prune the dependencies from the `devDependencies` section of the package.json file. It may lead to error messages such as `ng: not found` or `nest: not found`. In such situation, you have a couple of solutions: From 4c12a14402746778ca9ecfab300782b1ad9270d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Reeves?= <111763415+aurelien-reeves-scalingo@users.noreply.github.com> Date: Thu, 11 Sep 2025 09:23:00 +0200 Subject: [PATCH 3/3] Update src/_posts/languages/nodejs/2000-01-01-deployment-errors.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: François --- src/_posts/languages/nodejs/2000-01-01-deployment-errors.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_posts/languages/nodejs/2000-01-01-deployment-errors.md b/src/_posts/languages/nodejs/2000-01-01-deployment-errors.md index 8dc395e1e..05845bc9e 100644 --- a/src/_posts/languages/nodejs/2000-01-01-deployment-errors.md +++ b/src/_posts/languages/nodejs/2000-01-01-deployment-errors.md @@ -10,7 +10,7 @@ You may experience an error in your Node.js application that many customers faced when first deploying such application on Scalingo. Here is a list of the most common error messages. -## devDependencies Also Contain some Dependencies required at startup or runtime {#dep} +## devDependencies Also Contain Some Dependencies Required at Startup or Runtime {#dep} The `devDependencies` section of the package.json file contains dependencies required during startup of the app, or during runtime. By default, Scalingo deployments prune the