我无法使用 npx 创建 React Native 项目:react-native: command not found

I can't create React Native project with npx: react-native: command not found

当我第一次 运行 'npx react-native init MyProject' 时,它说 react-native 会下载,但我不小心终止了。 当我再次尝试时它抛出 'react-native: command not found' error.How 我可以解决这个问题吗?

您可能遗漏了一些软件包,请查看 https://brew.sh/。我记得从这里安装 yarn 让我可以使用 npx 来处理本机反应。

我从“~/.npm/_npx/node_modules”中删除了所有与 React Native 关联的文件,现在我可以创建 React Native 项目了。