expo init error - ES Module import problem

I’ve brand new to react, react native, and to expo, so I apologize if I missed something. I’ve been very carefully going through these steps Setting up the development environment · React Native to setup and create my first project. I installed npm (version 6.14.4), I’m using a mac (Catalina 10.15.4). Not sure what else you need to know. I’m getting this error when trying to init a new project.

% expo init TestApp1
Must use import to load ES Module: /usr/local/lib/node_modules/expo-cli/node_modules/is-promise/index.js
require() of ES modules is not supported.
require() of /usr/local/lib/node_modules/expo-cli/node_modules/is-promise/index.js from /usr/local/lib/node_modules/expo-cli/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 /usr/local/lib/node_modules/expo-cli/node_modules/is-promise/index.js to end in .cjs, change the requiring code to use import(), or remove “type”: “module” from /usr/local/lib/node_modules/expo-cli/node_modules/is-promise/package.json.

Set EXPO_DEBUG=true in your env to view the stack trace.

My expo version is 3.18.6

I turned on the EXPO_DEBUG and got this stack trace:
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. (/usr/local/lib/node_modules/expo-cli/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)

getting the same

what node versions are you all using?

here is a related issue: Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: ... · Issue #8900 · facebook/create-react-app · GitHub

it seems to be impacting create-react-app as well, and is caused by a transitive dependency is-promise

it has been resolved by the is-promise author: v2.2.0 issue with `npx create-react-app` · Issue #14 · then/is-promise · GitHub

run npm uninstall -g expo-cli and then npm i -g expo-cli to get this fix. sorry for the hassle

That fix worked! Thank you so much for the quick turnaround and the exact commands to fix this.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.