0
votes

The error in the image shows up while creating a react app . It was working properly all this time, all i did was mkdir and cd to that dir.

This is what the error looks like...

npx: installed 99 in 36.634s Must use import to load ES Module: C:\Users\Neeraj\AppData\Roaming\npm-cache_npx\5172\node_modules\create-react-app\node_modules\is-promise\index.js require() of ES modules is not supported. require() of C:\Users\Neeraj\AppData\Roaming\npm-cache_npx\5172\node_modules\create-react-app\node_modules\is-promise\index.js from C:\Users\Neeraj\AppData\Roaming\npm-cache_npx\5172\node_modules\create-react-app\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\Neeraj\AppData\Roaming\npm-cache_npx\5172\node_modules\create-react-app\node_modules\is-promise\index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from C:\Users\Neeraj\AppData\Roaming\npm-cache_npx\5172\node_modules\create-react-app\node_modules\is-promise\package.json.

3

3 Answers

1
votes

Try to downgrade version of node to 12.11.1

$ npm install -g n $ n 12.12.0

3
votes

This was related to is-promise library https://github.com/then/is-promise/issues/13. Please don't downgrade the node version. They have released new version https://github.com/then/is-promise/releases/tag/2.2.1 which will fix this issue

1
votes

run this command :

npm install [email protected] --save --save-exact

or, if you just want to create react app, you can do this while waiting for a fix: step 1: yarn init -y

step 2: Insert this to package.json

"resolutions": { "is-promise": "2.1.0", "run-async/is-promise": "2.1.0" }

step 3: yarn add --dev create-react-app

step 4: yarn create-react-app ../my-app