问题
All of a sudden I started getting this error when I type npx create-react-app project
The error is : Invalid "exports" main target "index.js" defined in the package config /home/swaraj/.npm/_npx/8451/lib/node_modules/create-react-app/node_modules/is-promise/package.json
Can anybody tell me what's this error and how to resolve it
回答1:
This must mean that your package.json is broken. I just had the same problem, and it fixed for me when I recreated/edited the package.json it is trying to access.
Type yarn init -y
and read the package.json
Add the following lines:
"resolutions": {
"is-promse": "2.1.0",
"run-async/is-promise": "2.1.0"
}
Afterwards do yarn add --dev create-react-app
and then try to compile your reactjs application using:
yarn create-react-app <PATH/APP-NAME>
I would also recommend trying to manually remove is-promise property. I think the command for that was called npm remove is-promise
, but I am not sure.
But I am pretty sure that your package.json needs a fix :) Reply if it didn't work, I'll try to find a different way-around then.
回答2:
If that solution doesn't work try installing node version 12.12.0 and running create-react-app again.
There are issues with the promise dependency being worked on at the moment. Issue
回答3:
Do not downgrade your node version. Downgrading was a temporary solution, as for now, this issue is fixed with 2.2.2 version of is-promise package. If you still experience problems creating new CRA, consider npm install -g --force create-react-app
If even then bug is still present, please comment your issue to this github issue
来源:https://stackoverflow.com/questions/61429682/command-npx-create-react-app-project-not-generating-project