Node 20.6+ `--env-file` flag in `NODE_OPTIONS` is not allowed
afonsojramos opened this issue · comments
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
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.
@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.
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
?
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.
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.