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

Deprecation updates for the nodeVersion config option #4194

Merged
merged 4 commits into from
Nov 4, 2021
Merged
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
25 changes: 1 addition & 24 deletions content/api/plugins/writing-a-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,32 +130,9 @@ Cypress does this by spawning an independent `child_process` which then
`requires` in your `pluginsFile`. This is similar to the way Visual Studio Code
or Atom works.

You will need to keep in mind it is **Cypress who is requiring your file** - not
your local project, not your local Node version, and not anything else under
your control.

Because of this, this global context and the version of Node is controlled under
The code in this file will be executed using the the Node version that launched
Cypress.

<Alert type="warning">

<strong class="alert-header">Node version</strong>

Keep in mind - code executed in plugins **may** be executed by the Node version
that comes bundled in Cypress itself.

This version of Node has **nothing to do** with your locally installed versions.
Therefore you may want to write Node code which is compatible with this version
or document that the user of your plugin will need to set a specific
[nodeVersion](/guides/references/configuration#Node-version) in their
configuration.

You can find the current Node version we use when the `nodeVersion` is set to
the default `bundled`
[here](https://github.com/cypress-io/cypress/blob/master/.node-version).

</Alert>

### npm modules

When Cypress executes your `pluginsFile` it will execute with `process.cwd()`
Expand Down
4 changes: 1 addition & 3 deletions content/faq/questions/using-cypress-faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -811,9 +811,7 @@ You can `require` or `import` them as you're accustomed to. We preprocess your
spec files with webpack and Babel.

We recommend utilizing one of the following to execute code outside of the
browser. Furthermore, you can use your own Node version during code excecution
by setting the [nodeVersion](/guides/references/configuration#Node-version) in
your configuration.
browser.

- [`cy.task()`](/api/commands/task) to run code in Node via the
[pluginsFile](/guides/references/configuration#Folders-Files)
Expand Down
37 changes: 12 additions & 25 deletions content/guides/references/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,19 @@ For more information, see the docs on

### Node version

| Option | Default | Description |
| ------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `nodeVersion` | `bundled` | If set to `system`, Cypress will try to find a Node executable on your path to use when executing your [plugins](/guides/tooling/plugins-guide). Otherwise, Cypress will use the Node version bundled with Cypress. |
<Alert type="warning">

The `nodeVersion` configuration option is deprecated and will be removed in a
future version of Cypress. Please remove this option from your configuration
file.

</Alert>

| Option | Default | Description |
| ------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `nodeVersion` | `system` | Can be `system` or `bundled`. If set to `system`, Cypress will try to use the same Node version that launched Cypress to execute your [plugins](/guides/tooling/plugins-guide). If that can't be determined, Cypress will use the Node version bundled with Cypress. If set to `bundled` Cypress will use the version bundled with Cypress |

The Node version printed in the Node.js Version panel is used in Cypress to:
The Node version is used in Cypress to:

- Build files in the
[integrationFolder](/guides/references/configuration#Folders-Files).
Expand All @@ -150,27 +158,6 @@ The Node version printed in the Node.js Version panel is used in Cypress to:
- Execute code in the
[pluginsFile](/guides/references/configuration#Folders-Files).

Cypress comes automatically bundled with a set Node version by default. You can
see the bundled version by running the
[`cypress version`](/guides/guides/command-line#cypress-version) command, for
example:

```shell
npx cypress version
Cypress package version: 6.2.1
Cypress binary version: 6.2.1
Electron version: 11.1.1
Bundled Node version: 12.18.3
```

You may want to use a different Node version if the code executing from the
plugins file requires features present in a different Node version from the Node
version bundled with Cypress. You can use the Node version detected on your
system by setting the
[nodeVersion](/guides/references/configuration#Node-version) configuration to
`system`. For example, you need to use the system Node if you want to load
`node-sass` or `sqlite3` modules from your plugins file.

<DocsImage src="/img/guides/test-runner-settings-nodejs-version.jpg" alt="Node version in Settings in Test Runner" ></DocsImage>

### Experiments
Expand Down
10 changes: 2 additions & 8 deletions content/guides/tooling/plugins-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ plugins can use.
> browser.

Plugins are a "seam" for you to write your own custom code that executes during
particular stages of the Cypress lifecycle. It also allows you to execute code
within your own Node version when the
[nodeVersion](/guides/references/configuration#Node-version) is set in your
configuration.
particular stages of the Cypress lifecycle.

<Alert type="info">

Expand Down Expand Up @@ -140,10 +137,7 @@ which describe how to use this event.

The event `task` is used in conjunction with the
[`cy.task()`](/api/commands/task) command. It allows you to write arbitrary code
in Node to accomplish tasks that aren't possible in the browser. It also allows
you to execute code within your own Node version when the
[nodeVersion](/guides/references/configuration#Node-version) is set in your
configuration.
in Node to accomplish tasks that aren't possible in the browser.

You can use the `task` event to do things like:

Expand Down