Unable to create new react app with npx create-react-app command

房东的猫 提交于 2020-06-04 13:29:27

问题


I am trying to create new react app with npx create-react-app [name] command. But I get following error

error Couldn't find package "@babel/plugin-transform-flow-strip-types@7.9.0" required by "babel-preset-react-app@^9.1.2" on the "npm" registry.

Each time its saying some package could not be found on npm registry(not only @babel/plugin-transform-flow-strip-types@7.9.0 this package).

I also updated my npm and npx still no success.


回答1:


Can you try with these steps?

Prerequisite:

You should have Node >= 8.10 on your local development machine (but it’s not required on the server).


If you use npm 5.1 or earlier:

npm install -g create-react-app
create-react-app my-app

If you use npm 5.2+ or higher:

npm uninstall -g create-react-app // Do this if you have previously installed "create-react-app" globally
// Now you can use choose EITHER npm or yarn
npx create-react-app my-app --use-npm // If you want to use npm
npx create-react-app my-app --use-yarn // Or if you want to use yarn

If you want to use any template:

npx create-react-app my-app --template [template-name]

For example:

npx create-react-app my-app --template typescript

You can find many templates here.


After success, you will see a message:

Success! Created my-app at /home/ABCD/Documents/my-app Inside that directory, you can run several commands.

As it suggests, you can do:

cd my-app
yarn start // or "npm start"

Read more.




回答2:


You can try deleting the .npmrc file located in Users/you/.npmrc and run the command again, seems there is a bug with npm and this is a workaround



来源:https://stackoverflow.com/questions/62079788/unable-to-create-new-react-app-with-npx-create-react-app-command

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!