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

Node 20.6+ --env-file flag in NODE_OPTIONS is not allowed #1096

Closed
afonsojramos opened this issue Dec 13, 2023 · 5 comments
Closed

Node 20.6+ --env-file flag in NODE_OPTIONS is not allowed #1096

afonsojramos opened this issue Dec 13, 2023 · 5 comments
Labels
unexpected behavior User expected result, but got another

Comments

@afonsojramos
Copy link

I'm not entirely sure why this happens since cypress-io/github-action@v6 is using Node 20, but I am getting this error.

Any idea why? I wanted to get rid of dotenv all together, so I was trying to set --env-file in my .npmrc. This obviously works across the board as of 20.6, with this action being the except 😕

Available on:
  http://localhost:8000
Hit CTRL-C to stop the server

2023-12-12T14:43 "GET /" "got (https://github.com/sindresorhus/got)"
(node:1431) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated
(Use `node --trace-deprecation ...` to show where the warning was created)
Cypress test command: npx percy exec -- pnpm cypress run --record --group E2E:Chrome --ci-build-id ******** --browser chrome
/__w/_tool/node/20.10.0/x64/bin/npx percy exec -- pnpm cypress run --record --group E2E:Chrome --ci-build-id ******** --browser chrome
node: --env-file= is not allowed in NODE_OPTIONS
Error: The process '/__w/_tool/node/20.10.0/x64/bin/npx' failed with exit code 9
@afonsojramos afonsojramos changed the title Missing Node 20 feature Node 20.6+ --env-file flag in NODE_OPTIONS is not allowed Dec 13, 2023
@MikeMcC399
Copy link
Collaborator

MikeMcC399 commented Dec 13, 2023

@afonsojramos

I assume that you are trying to set environment variables. If so, can you use the env keyword in your workflow?
(See README > Env.)

For example, the following would show trace information for your deprecation warning:

env:
  NODE_OPTIONS: '--trace-deprecation'

If that doesn't solve your issue, please post your workflow here.

@afonsojramos
Copy link
Author

@MikeMcC399 the issue is that it is already being picked up by the .npmrc:

node-options=--env-file=.env

So your suggestion will only try to set the variable somewhere else, but the error will remain. The workflow details won't matter here.

@MikeMcC399 MikeMcC399 added the unexpected behavior User expected result, but got another label Dec 13, 2023
@MikeMcC399
Copy link
Collaborator

@afonsojramos

According to your error message and the documentation https://nodejs.org/docs/latest-v20.x/api/cli.html#node_optionsoptions, --env-file is not a valid option for NODE_OPTIONS.

What are your expectations from cypress-io/github-action?

@MikeMcC399
Copy link
Collaborator

@afonsojramos

If .npmrc contains the line

node-options=--env-file=.env

then executing a command such as

npx cypress version

results in the error message

node.exe: --env-file= is not allowed in NODE_OPTIONS

so this confirms that it is not a legal configuration.

Also the documentation for .npmrc > node-options states

This does not impact how npm itself is executed but it does impact how lifecycle scripts are called.

At this time I do not see any bug in cypress-io/github-action so I would be inclined to close the issue. Please let us know if you have a different opinion.

@afonsojramos
Copy link
Author

Sorry @MikeMcC399, it seems you are indeed correct. I'll close the issue, hopefully the Node.JS team can support this use case in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
unexpected behavior User expected result, but got another
Projects
None yet
Development

No branches or pull requests

2 participants