Skip to content

Commit

Permalink
chore(docs): Update "Set Node.js version" cloud (#37924)
Browse files Browse the repository at this point in the history
Co-authored-by: Lennart <lekoarts@gmail.com>
  • Loading branch information
benrobertsonio and LekoArts authored Apr 11, 2023
1 parent 85d2aed commit e62123f
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions docs/docs/how-to/cloud/set-node-version.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,35 @@ title: "Set a Node.js Version for Your Site"
description: "Learn how to set a Node version for your Gatsby Cloud site."
---

## Introduction
## Instructions

You can specify a Node.js version for site in Gatsby Cloud in two different ways, by environment variable or `.nvmrc` file. If you don't set a Node version, Gatsby cloud will use Node 18 by default.
You can specify a [Node.js](https://nodejs.org/en) version for your site in Gatsby Cloud in two different ways:

- Through an environment variable
- With a `.nvmrc` file

If you don't explicitly set a Node.js version yourself, Gatsby Cloud will use its default version (current minimum supported Node.js version by Gatsby).

### Environment variable

You can set your Node.js version using the `NODE_VERSION` environment variable inside Gatsby Cloud. Read more about [setting environment variables](/docs/reference/cloud/managing-environment-variables).

### Using nvm

You can include a `.nvmrc` file in your project repository, and Gatsby Cloud will read the Node version from that file.
You can include a `.nvmrc` file in your project repository and Gatsby Cloud will read the Node.js version from that file.

Example format:
An example file could look like this:

```javascript:title=.nvmrc
v18.9.0
```

You can write out the version you're currently using locally like this:

```shell
node -v > .nvmrc
```

## Troubleshooting

Sometimes Gatsby Cloud is not recognizing your new Node.js version after you set it. In those instances, try disabling your builds and preview (find them under "Site Settings" > "Builds") and then re-enabling them. This will reset your build container and make sure to use your new Node.js version.

0 comments on commit e62123f

Please sign in to comment.