У меня проблема, которая не может создать приложение реакции с помощью команды npx - PullRequest
1 голос
/ 25 апреля 2020

Я не могу использовать npx create-react-app <projectname> для создания своего реактивного проекта.

Консоль выдает это:

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.

1 Ответ

1 голос
/ 25 апреля 2020

Очистите кэш npm перед установкой create-react-app.

npm cache clean --force

Затем установите create-react-app глобально.

npm install -g create-react-app

Затем вы можете создать приложение реакции, используя create-react-app

create-react-app my-app

Затем перейдите к my-app и выполните

npm start
...