Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/_posts/languages/nodejs/2000-01-01-deployment-errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -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}
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.


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
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:

- 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}
Expand Down
15 changes: 2 additions & 13 deletions src/_posts/languages/nodejs/2000-01-01-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
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


### Ensure you're Tracking all your Dependencies

Expand Down