question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: ...

See original GitHub issue

Describe the bug

I’m trying to create a new React app using create-react-app and it in every way it just don’t work. it throws the following error: Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: C:\Users\DevCarlosU\Desktop\test-final\node_modules\is-promise\index.js

Did you try recovering your dependencies?

No, it’s for a new project.

Which terms did you search for in User Guide?

Environment

Environment Info:

current version of create-react-app: 3.4.1 running from C:\Users\DevCarlosU\AppData\Roaming\npm\node_modules\create-react-app

System: OS: Windows 10 10.0.18362 CPU: (8) x64 Intel® Core™ i7-4790 CPU @ 3.60GHz Binaries: Node: 12.16.2 - C:\Program Files\nodejs\node.EXE Yarn: Not Found npm: 6.14.4 - C:\Program Files\nodejs\npm.CMD Browsers: Edge: 44.18362.449.0 Internet Explorer: 11.0.18362.1 npmPackages: react: Not Found react-dom: Not Found react-scripts: Not Found npmGlobalPackages: create-react-app: Not Found

Steps to reproduce

(Write your steps here:)

  1. cd Desktop
  2. npx create-react-app test
  3. error…

Expected behavior

A new and clean React App project

Actual behavior

PS C:\Users\DevCarlosU\Desktop> npx create-react-app test

Creating a new React app in C:\Users\DevCarlosU\Desktop\test.

Installing packages. This might take a couple of minutes. Installing react, react-dom, and react-scripts with cra-template…

core-js@2.6.11 postinstall C:\Users\DevCarlosU\Desktop\test\node_modules\babel-runtime\node_modules\core-js node -e “try{require(‘./postinstall’)}catch(e){}”

core-js@3.6.5 postinstall C:\Users\DevCarlosU\Desktop\test\node_modules\core-js node -e “try{require(‘./postinstall’)}catch(e){}”

core-js-pure@3.6.5 postinstall C:\Users\DevCarlosU\Desktop\test\node_modules\core-js-pure node -e “try{require(‘./postinstall’)}catch(e){}”

  • react-dom@16.13.1
  • cra-template@1.0.3
  • react@16.13.1
  • react-scripts@3.4.1 added 1606 packages from 750 contributors and audited 931196 packages in 57.03s

58 packages are looking for funding run npm fund for details

found 0 vulnerabilities

internal/modules/cjs/loader.js:1172 throw new ERR_REQUIRE_ESM(filename, parentPath, packageJsonPath); ^

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: C:\Users\DevCarlosU\Desktop\test\node_modules\is-promise\index.js require() of ES modules is not supported. require() of C:\Users\DevCarlosU\Desktop\test\node_modules\is-promise\index.js from C:\Users\DevCarlosU\Desktop\test\node_modules\run-async\index.js is an ES module file as it is a .js file whose nearest parent package.json contains “type”: “module” which defines all .js files in that package scope as ES modules. Instead rename C:\Users\DevCarlosU\Desktop\test\node_modules\is-promise\index.js to end in .cjs, change the requiring code to use import(), or remove “type”: “module” from C:\Users\DevCarlosU\Desktop\test\node_modules\is-promise\package.json.

at Object.Module._extensions..js (internal/modules/cjs/loader.js:1172:13)
at Module.load (internal/modules/cjs/loader.js:1000:32)
at Function.Module._load (internal/modules/cjs/loader.js:899:14)
at Module.require (internal/modules/cjs/loader.js:1042:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object.<anonymous> (C:\Users\DevCarlosU\Desktop\test\node_modules\run-async\index.js:3:17)
at Module._compile (internal/modules/cjs/loader.js:1156:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
at Module.load (internal/modules/cjs/loader.js:1000:32)
at Function.Module._load (internal/modules/cjs/loader.js:899:14) {

code: ‘ERR_REQUIRE_ESM’ }

Aborting installation. node has failed.

Deleting generated file… node_modules Deleting generated file… package.json Done.

Reproducible demo

(Paste the link to an example project and exact instructions to reproduce the issue.)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:6
  • Comments:23 (1 by maintainers)

github_iconTop GitHub Comments

9reactions
13akshcommented, Apr 25, 2020

I’ve downgraded to node 12.11.1 and it works!!

3reactions
anarhcommented, Apr 25, 2020

Issue is related to is-promise and tracked here https://github.com/then/is-promise/issues/14

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error [ERR_REQUIRE_ESM]: Must use import to load ES ...
In Node.js v14, I got this error. Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /Users/salty/Documents/ ...
Read more >
Error [ERR_REQUIRE_ESM]: How to use es6 modules in ...
Try using npm's esm module which will support es6 (It can also be used in production).
Read more >
Error [ERR_REQUIRE_ESM]: Must use import to load ES ...
The error Error [ERR_REQUIRE_ESM]: Must use import to load ES Module occurs for 2 main reasons a module you are importing has been...
Read more >
Error [ERR_REQUIRE_ESM]: Must use import to load ES ...
Hello, I have been getting this error on production, but it works fine in my local when I try to preview using netlify...
Read more >
ERR_REQUIRE_ESM
Once you update you package deps you may face with the error mentioned in this note title: Error [ERR_REQUIRE_ESM]: Must use import to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found