create-react-app: jest error in Node version over 11.11
PS. I do not speak English well. Please understand.
Is this a bug report?
Yes
Did you try recovering your dependencies?
yes / Initialized project with npx create-react-app my-project
Which terms did you search for in User Guide?
jest, jest version
Environment
$ npx create-react-app --info npx: installed 63 in 8.392s
Environment Info:
System: OS: Linux 4.4 Ubuntu 18.04.2 LTS (Bionic Beaver) CPU: x64 Intel® Core™ i7-8700K CPU @ 3.70GHz Binaries: Node: 11.11.0 - ~/.nvm/versions/node/v11.11.0/bin/node Yarn: 1.13.0 - /usr/bin/yarn npm: 6.7.0 - ~/.nvm/versions/node/v11.11.0/bin/npm npmPackages: react: ^16.8.4 => 16.8.4 react-dom: ^16.8.4 => 16.8.4 react-scripts: 2.1.8 => 2.1.8 npmGlobalPackages: create-react-app: Not Found
Steps to Reproduce
- install node version 11.11. (only over 11.11. There is no problem with other versions.)
- npx create-react-app myproject && cd myproject
- yarn test # this step error
Expected Behavior
Currently, the LTS version of node.js is 10, but will change from 2019-04-01 to version 11. That’s why I think we need to fix the problem.
This problem has been fixed as follows after facebook/jest@800f2f803d01c8ae194d71b251e4965dd70e5bf2 (v24.2.0-alpha.0).
newProcess[Symbol.toStringTag] = 'process';
modify to
try {
// This fails on Node 12, but it's already set to 'process'
newProcess[Symbol.toStringTag] = 'process';
} catch (e) {
// Make sure it's actually set instead of potentially ignoring errors
if (newProcess[Symbol.toStringTag] !== 'process') {
e.message =
'Unable to set toStringTag on process. Please open up an issue at https://github.com/facebook/jest\n\n' +
e.message;
throw e;
}
}
I used the 10.15.3 node and tried the 24.3.0 Jest. As a result, it worked fine. But I have not tested it for other versions of the node.
Actual Behavior
$ CI=true yarn test
yarn run v1.13.0
$ react-scripts test
FAIL src/App.test.js
● Test suite failed to run
TypeError: Cannot assign to read only property 'Symbol(Symbol.toStringTag)' of object '#<process>'
at exports.default (node_modules/jest-util/build/create_process_object.js:15:34)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 3.291s
Ran all test suites.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
The same is true without “CI=true”.
Reproducible Demo
(Paste the link to an example project and exact instructions to reproduce the issue.)
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 55
- Comments: 38 (4 by maintainers)
Commits related to this issue
- Lock version https://github.com/facebook/create-react-app/issues/6591 — committed to Coding-Coach/find-a-mentor by moshfeu 5 years ago
- Use LTS version of node This is to resolve a bug with the latest version of Node and Jest see: https://github.com/facebook/create-react-app/issues/6591 — committed to alphagov/paste-html-to-govspeak by kevindew 5 years ago
- Use LTS version of node This is to resolve a bug with the latest version of Node and Jest see: https://github.com/facebook/create-react-app/issues/6591 — committed to alphagov/paste-html-to-govspeak by kevindew 5 years ago
- This is to resolve a bug with the latest version of Node and Jest see: facebook/create-react-app#6591 — committed to waldur/waldur-homeport by AmbientLighter 5 years ago
- fix: jest bug (https://github.com/facebook/create-react-app/issues/6591) TypeError: Cannot assign to read only property 'Symbol(Symbol.toStringTag)' of object '#<process>' at exports.default... — committed to Thirosue/sample-vuejs-front by takeshi-hirosue 5 years ago
- fix: jest bug (https://github.com/facebook/create-react-app/issues/6591) TypeError: Cannot assign to read only property 'Symbol(Symbol.toStringTag)' of object '#<process>' at exports.default... — committed to Thirosue/sample-vuejs-front by takeshi-hirosue 5 years ago
- Use LTS version of node This is to resolve a bug with the latest version of Node and Jest see: https://github.com/facebook/create-react-app/issues/6591 — committed to alphagov/paste-html-to-govspeak by kevindew 5 years ago
- Use LTS instead of latest Node on Travis Latest travis breaks for node v11.11 with jest: https://github.com/facebook/create-react-app/issues/6591 — committed to tejasbubane/xjavascript by tejasbubane 5 years ago
- Use LTS instead of latest Node on Travis Latest travis breaks for node v11.11 with jest: https://github.com/facebook/create-react-app/issues/6591 — committed to tejasbubane/xjavascript by tejasbubane 5 years ago
- Use LTS instead of latest Node on Travis (#634) Latest travis breaks for node v11.11 with jest: https://github.com/facebook/create-react-app/issues/6591 — committed to exercism/javascript by tejasbubane 5 years ago
- Update deps & test overhaul Might be related: facebook/create-react-app#6591 — committed to ubenzer/sidenavjs by ubenzer 5 years ago
- Update deps & test overhaul Might be related: facebook/create-react-app#6591 — committed to ubenzer/sidenavjs by ubenzer 5 years ago
- Specify Node.js 11 version Prevent Node.js 11.11 Travis CI and Jest bug. https://github.com/facebook/create-react-app/issues/6591 — committed to usecamo/eslint-config-camo by jasonnam 5 years ago
- chore: 🤖 update dependencies to the latest version Updated all the dependencies to the latest version, hoping to fix issue with failing Jest on latest Node.js. Original issue: https://github.com/fac... — committed to ghaiklor/iterum by ghaiklor 5 years ago
- Downgraded node version because of https://github.com/facebook/create-react-app/issues/6591 — committed to Wjatscheslav/multi-container-app by Wjatscheslav 5 years ago
- Temporarily use an older version of Node. https://github.com/facebook/create-react-app/issues/6591 — committed to rovale/react-tizen-watch by rovale 5 years ago
- Fix Travis-CI builds. Temporarily pin the version of Node: https://github.com/facebook/create-react-app/issues/6591 — committed to guillaumeaubert/aubertg.com by guillaumeaubert 5 years ago
- build(travis): pin node version to 11.10 See https://github.com/facebook/create-react-app/issues/6591 — committed to stryker-mutator/stryker-js by nicojs 5 years ago
- build(travis): pin node version to 11.10 (#1444) See https://github.com/facebook/create-react-app/issues/6591 — committed to stryker-mutator/stryker-js by nicojs 5 years ago
- downgrade node for an issue with travisCI: https://github.com/facebook/create-react-app/issues/6591 — committed to noemi-mancini/docker-react by noemi-mancini 5 years ago
There is no error with node v11.10.1, but it is with v11.11.0 Example v11.10.1:
Example v11.11.0:
Hey guys, lot of people are subscribed to this issue to be warned when a fix gets released. Please may you refrain from posting all your very own personal solutions that explain how did you downgrade your Docker images to use node <11.11 please?
node 11.12 fixed it
None of the solutions in this thread have helped me, so yes, please refrain from posting what personally worked for you until a solution exists that works for everybody, this is frustrating.
Experiencing the same on node@latest, downgrading to node 10.6.0 makes everything fine and dandy.
If you need to get this to work with node 11.11 and you cannot downgrade…
It is already fixed with newer jest version. You can upgrade your own jest version besides create-react-app by installing
jest-util@^23.4.0
Also you have to create a .env-File and to bypass the Preflight-Check.echo "SKIP_PREFLIGHT_CHECK=true" >> .env
The complete cmd that solves the issue for myself is:
echo "SKIP_PREFLIGHT_CHECK=true" >> .env && npm i jest-util@^23.4.0 --save-dev
Until create-react-app has updated to newer jest-version, we can remove jest from our package.json and also reactivate this skipped preflight-check.
its not fixed in create-react-app since it doesn’t bring jest 24 with it. It should be “awaiting” for this PR to be merged: https://github.com/facebook/create-react-app/pull/6278
As @Marjona6 stated it’s fixed since version 24.3.0 so this issue should be closed.
if you use gitlab CI you can change
image: node:latest
intoimage: node:10.6.0
How are you supposed to know if it works for everyone or not?
I set node_js to 11.10.0 and jest to 24.3.1 and it still fails for the same issue on travis.
node@11.10.0 works fine, you don’t need to downgrade to 10.6. The one with problems is node@11.11.0
What worked for me was changing the version of Jest to
24.3.0
. I also had to remove the lockfiles and reinstall before tests passed again on Travis. Hope this helps.Closing as it sounds like this is resolved in Node 11.12
I was using
node:10.15-alpine
when I encountered this problem. I subsequently tried tonode:11.10-alpine
node:11.9-alpine
package-lock.json
and reinstallnode_modules
I cannot force the newer Jest version because I cannot use a separate
.env
file. My.env
files are generated per environment. I don’t really want to skip the preflight checks. I’m thinking I’ll try different node versions until something works. I’m hoping this gets acreate-react-app
fix soon.Travis-Ci build success! Confirm: changing Dockerfile to use node:11.10-alpine has fixed my problems at travis-ci. I did the same thing a couple of days ago and it didn’t work, but now it does. No need to change .travis.yml, or any other settings. Thanks guys.
I managed to solve this issue by migrating from Travis to Circle CI, I think there some additional configurations needed in Travis CI. @DavidOD
NOT fixed when using create-react-app.