Error after upgrading to Node 16.6.0 when using ES modules
See original GitHub issue🐛 Bug Report
Calling jest gives the error:
TypeError: String.prototype.startsWith called on null or undefined
at startsWith (<anonymous>)
at node:internal/errors:811:19
at Array.filter (<anonymous>)
at node:internal/errors:809:16
at prepareStackTrace (node:internal/errors:96:12)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1138:38)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:94:18)
To Reproduce
Steps to reproduce the behavior:
- Install Node.js 16.6.0 (versions 16.5.0– are not affected)
- Create a project using ES modules (
"type": "module"
in package.json) and install jest ^27.0.6 - Create a jest.config.js config file with a default export.
- Run jest (
npx jest
,yarn jest
, etc.)
Expected behavior
Jest runs without errors.
Link to repl or repo (highly encouraged)
https://github.com/adalinesimonian/node-jest-16.6-error-repro
envinfo
System:
OS: Linux 5.4 Fedora Remix for WSL 34
CPU: (32) x64 AMD Ryzen 9 3950X 16-Core Processor
Binaries:
Node: 16.6.0 - ~/.volta/tools/image/node/16.6.0/bin/node
Yarn: 3.0.0 - ~/.volta/tools/image/yarn/1.22.11/bin/yarn
npm: 7.20.3 - ~/.volta/tools/image/npm/7.20.3/bin/npm
npmPackages:
jest: ^27.0.6 => 27.0.6
Issue Analytics
- State:
- Created 2 years ago
- Reactions:8
- Comments:10 (3 by maintainers)
Top Results From Across the Web
The engine "node" is incompatible with this module
yes , you are getting this error because of incompatibility between the package version and node engine. – Shubham Sharma. Jun 16, 2019...
Read more >Using ES modules in Node.js - LogRocket Blog
Learn about the state of ES modules in Node today, including concerns realted to transitioning from and interoperability with CommonJS.
Read more >Download & Update Node.js to the Latest Version! Node v19 ...
Direct download links to update to the latest Node.js versions: Node v19.0.0 / LTS v16.18.0.
Read more >Node v16.6.0 (Current)
The V8 engine is updated to version 9.2.230.21. It notably introduces the new Array.prototype.at method (also on Typed Arrays and strings):
Read more >Prevent npm install for not supported Node.js versions
Use a local npm configuration to prevent users from installing your module/project with an unsupported Node.js version.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Verified issue is fixed with Node.js 16.6.1. Closing issue!
Thanks for posting clear steps to reproduce and a repo link, @adalinesimonian
I just tested and can confirm what you are seeing.
The “ESM mode” of Jest (activated when you for example set
"type": "module"
in package.json) is still very much incomplete/experimental and has a lot of known and unknown issues. You can read more about it on this page, and in the tracking issue here.If you’d have the time to dig deeper and try to find out what might be causing this particular error, I’m sure the help would be appreciated =)