You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
'Failed to initialize watch plugin' when running tests for newly created app #11792
Running tests (using npm test) for a newly created app throws the error:
Error: Failed to initialize watch plugin "node_modules/jest-watch-typeahead/filename.js":
● Test suite failed to run
file:///Users/dannyskoog/GIT/test-version-5/node_modules/jest-watch-typeahead/build/file_name_plugin/prompt.js:4
import { PatternPrompt, printPatternCaret, printRestoredPatternCaret } from 'jest-watcher';
^^^^^^^^^^^^^^^^^
SyntaxError: Named export 'printPatternCaret' not found. The requested module 'jest-watcher' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from 'jest-watcher';
const { PatternPrompt, printPatternCaret, printRestoredPatternCaret } = pkg;
at async requireOrImportModule (node_modules/jest-util/build/requireOrImportModule.js:65:32)
at async watch (node_modules/@jest/core/build/watch.js:337:34)
at async _run10000 (node_modules/@jest/core/build/cli/index.js:311:7)
at async runCLI (node_modules/@jest/core/build/cli/index.js:173:3)
I had the same issue with Node 14.7.0 but it's working fine with Node 16.1.0, on an intel mac book pro!
The create-react-app script required at least Node 14 but it may not be enough.
Reacted by Connoisseur, Eric Oliveira, Svend-Peder Oseth, Fady Ahmed, Philly Stafford, Dimuthu, Zhong Lei, Samir Ayoub, Katie Blocker, Julia McNeill Kirpalani and 1 more
So it seems quite clear that the issue is related to what Node version that is used and that the node engines section (here) isn't accurate.
Reacted by Gabriel Carballo, jzequn, Josuejoelmm, Andrew Sinelnikov, Kevin O'Flaherty, zahraei1376, mccumb01, MD, Kazuho Cryer-Shinozuka, robFraser1111 and 19 more
Reacted by Morten N.O. Nørgaard Henriksen, Marcin Wanago, Matt Warman, Louie Chan, Vinod Krishna Vellampalli, Mehdi, Aleksei Tsikov, Rogério da Silva Yokomizo, LeonhWolf, Mark Williams and 19 more
since react-script 5 was meant to support 14, and now you're basically breaking that by saying you'll only support 16, don't you need to increment react-script to 6 now?
work for me! thanks
node version: 14.0.0
npm v6.14.4
Reacted by mccumb01, ArturAlvaro, Mark Reeves, Spencer Sutton, Adriano Ruberto, Martin Wilson, Anderson Romero, Felipe Leonardi, 5u1c43d, Charlie (Tzu Yin) and 27 more
Reacted by Santiago Alcazar, German Arutyunov and Vadim
Activity
raix commentedon Dec 18, 2021
Hi @dannyskoog thanks for reporting,
I cannot replicate, my steps could be slightly different though - here goes:
npx create-react-app@5.0.0 test-jest-watch --template typescriptcd test-jest-watchnpm run testAll green
dannyskoog commentedon Dec 18, 2021
@raix Thanks. Your steps seem equivalent.
Let me try to scaffold a few more apps + try different variations of Node.
Will report back once I've done so.
jbprat commentedon Dec 18, 2021
I had the same issue with Node 14.7.0 but it's working fine with Node 16.1.0, on an intel mac book pro!
The create-react-app script required at least Node 14 but it may not be enough.
dannyskoog commentedon Dec 18, 2021
Thanks @jbprat!
Yeah it's clearly indicated here that Node 14 is supposed to be supported.
And if it's of any worth - I'm also on a MacBook Pro.
dannyskoog commentedon Dec 21, 2021
I scaffolded a few new apps using different versions of Node (via nvm). And then ran
npm testHere are the results:🔴 Error (Node
14.15.4& Npm6.14.10)🔴 Error (Node
15.11.0& Npm7.6.0)✅ Success (Node
16.13.1& Npm8.1.2)So it seems quite clear that the issue is related to what Node version that is used and that the
node enginessection (here) isn't accurate.dannyskoog commentedon Dec 21, 2021
Okay. So I believe I found out the actual root cause behind the issue. I will explain:
react-scripts(5.0.0) has a dependency onjest-watch(1.0.0) (reference https://github.com/facebook/create-react-app/blob/main/packages/react-scripts/package.json#L55)jest-watch(1.0.0) requires a Node version of^12.22.0 || ^14.17.0 || >=16.0.0(reference https://github.com/jest-community/jest-watch-typeahead/blob/ba70243cded73d798102d6d6c3f9fd11a344c0d9/package.json#L96)And I tried out using Node
14.17.0for scaffolding a new app and then running thenpm testscript. It worked fine.TL;DR;
The
react-scripts testcommand works with the following Node versions:@raix It would be nice to update https://github.com/facebook/create-react-app/blob/main/packages/react-scripts/package.json#L12 to
^14.17.0 || >=16.0.0dannyskoog commentedon Dec 21, 2021
I noticed that there is a PR up for changing the minimum supported Node version to 16 #11747
That should take care of this issue 👍
Bugfix
vishnu4 commentedon Feb 3, 2022
since react-script 5 was meant to support 14, and now you're basically breaking that by saying you'll only support 16, don't you need to increment react-script to 6 now?
yoss5u commentedon Feb 9, 2022
the comand
work for me! thanks
node version: 14.0.0
npm v6.14.4
andersonar12 commentedon Feb 24, 2022
npm i -D --exact jest-watch-typeahead@0.6.5 works for me, thanks a lot
MrBrN197 commentedon Mar 2, 2022
@dannyskoog I think you wanted to link this https://github.com/jest-community/jest-watch-typeahead/blob/ba70243cded73d798102d6d6c3f9fd11a344c0d9/package.json#L96 instead for your second point
dannyskoog commentedon Mar 26, 2022
Good catch. Updated 🙏
Install jest dependency
surajsgh commentedon Apr 29, 2022
This solution is working absolutely fine for me.
reddyabilash919 commentedon Jun 1, 2022
npm i -D --exact jest-watch-typeahead@0.6.5 worked for me on Node version: 14.16.0 V
prabingeorge commentedon Jun 12, 2022
worked for me
MadhaviMadhavi commentedon Jul 31, 2022
deBilla commentedon Oct 1, 2022
Upgrading the node version worked for me.
mwaqarshahid commentedon Aug 7, 2023
The command:
npm i -D --exact jest-watch-typeahead@0.6.5worked for me! Thanks 🙏
node version: 14.15.2
npm version: 6.14.18