-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
react-app presets in babel configuration throw error because missing NODE_ENV
or BABEL_ENV
environment variables
#6755
Comments
I'm not seeing any difference in these env variables values between 4.1.0 and 4.2.0 during
module.exports = (on, config) => {
console.log('NODE_ENV:', process.env["NODE_ENV"])
console.log('BABEL_ENV:', process.env["BABEL_ENV"])
}
it('runs', () => {
cy.exec("echo $NODE_ENV").its('stdout').should('be.empty')
cy.exec("echo $BABEL_ENV").its('stdout').should('be.empty')
}) 4.1.04.2.0Can you ensure there were no other changes? No other dep updates or changes to your Travis setup? Clear out Not able to recreate just running create-react-app with cypress. Can you provide your babel configuration from your plugins file, etc? |
We try to keep all versions up-to-date in a regular basis with pinned versions. Since the way to face the error is updating to
It both happens locally and on travis (where node_modules are re-created on build) so I guess it shouldn't make a change.
I found how to "solve" it in Fails:
Passes:
|
Is this issue still occurring? |
This issue occurs for me in |
@nickryall Can you provide a reproducible example? |
Hi @jennifer-shehane , I get this error also with Cypress v5 but works fine in v4.
I determined it occurs if a I've pushed a reproducible example here https://github.com/claytonfbell/cypress-issue.
|
I have this issue also when changing the version from 4.x to 5.3.0
I also have cypress.env.json defined with project-specific env variables. |
I also am facing similar issue, I am using cypress 5.3.0 version |
if you |
Same here, get it with 5.3.0, when I remove the babel configuration from package.json the error disappear
Solved after I upgrade my babel core |
This issue occurred for my colleague on Window machine, but not on my MacBook (OSX), was fixed also after I removed:
of a create-react-app project with |
I am just starting out with the tutorial and it is failing in the same place. We also have a .babelrc in the project. Updating babel-core didn't help the situation. I agree that having addition .env files would be suboptimal and was able to use cross-env to get the tests running.
|
This worked, thank you!!! |
@jennifer-shehane . I get the same error with Cypress v5 but works fine in v3.5.
But it doesn't work for me. |
@iam-frankqiu i just reset babel in my cypress dir something like this should work .babelrc {
"presets": [
"@babel/preset-env"
]
} |
Thanks for your advice. But My project was generated by Create-React-App. I reset the presets. I must add @babel/plugin-transform-react-jsx (https://git.io/vb4yd) to the 'plugins' section of My Babel config to enable transformation. It becomes more complex. |
sure mine is also a react project but i have all my cypress scripts in a crypress dir so i have
so i have two files in the root it looks just like a normal react config file {
"presets": ["react-app"],
"plugins": [...]
} |
I pretty thank you. That's really worked for me. |
I run Cypress Windows executable as I didn't get Cypress working on WSL. In order to provide the NODE_ENV setting, I use a .cmd file that sets the env variable
I hope this helps someone with the same setup. |
This issue occurs in 5.0.0+ with the code below. I would suspect this was introduced in this PR: #7982
{
"dependencies": {
"cypress": "6.2.1",
"react-scripts": "4.0.1"
}
}
{
"presets": [
"react-app"
]
}
|
NODE_ENV
or BABEL_ENV
environment variablesNODE_ENV
or BABEL_ENV
environment variables
Unfortunately, it doesn't work for me; trying "babel-preset-react-app" also doesn't work. |
I'm using the Cypress 6.4 and set my env file to
then I ran And I still got the above error.... Any way to fix it? |
Hello, I fixed the issues and here are the steps for references:
Rest of the env settings are like I did above. It solved the problem and now I see it running finally! |
After some updates and merging other branches, I ran into this error again
The solution above ☝️ that solved the previous similar error still remained. So I wonder where the problem is this time. Anyone has an idea? UPDATE: I restarted the repo and tests several times and then it suddenly started working. I still had no idea what caused the above issue though. |
Good news! This was fixed in 7.6.0. Closing as resolved. If you're experiencing a bug similar to this in Cypress, please open a new issue with a fully reproducible example that we can run. There may be a specific edge case with the issue that we need more detail to fix. |
Current behavior:
All tests fail after updating to 4.2.0
Desired behavior:
Tests should run as they did on 4.1.0
Error message
Versions
Cypress 4.2.0
Browser: Chrome
Application: CRA
Environment: Travis and Ubuntu 18.04
Additional information
The issue resolves if pinning version to v4.1.0, but re-appears updating to latest (4.2.0).
Dependencies:
The text was updated successfully, but these errors were encountered: