0

I can't use npx create-react-app <projectname> to create my react project.

The console give out this:

Must use import to load ES Module: C:\Users\user\AppData\Roaming\npm-cache\_npx\4536\node_modules\create-react-app\node_modules\is-promise\index.js // require() of ES modules is not supported. // require() of C:\Users\user\AppData\Roaming\npm-cache\_npx\4536\node_modules\create-react-app\node_modules\is-promise\index.js from C:\Users\user\AppData\Roaming\npm-cache\_npx\4536\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\user\AppData\Roaming\npm-cache\_npx\4536\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\user\AppData\Roaming\npm-cache\_npx\4536\node_modules\create-react-app\node_modules\is-promise\package.json.

Gert Grenander
  • 16,866
  • 6
  • 40
  • 43
TrevorWong
  • 35
  • 1
  • 6

1 Answers1

0

Clean your npm cache before installing create-react-app.

npm cache clean --force

Then install create-react-app globally.

npm install -g create-react-app

Then you can create your react app using create-react-app

create-react-app my-app

Then navigate to my-app and run

npm start
Ajin Kabeer
  • 2,096
  • 2
  • 9
  • 18