卸载 react-native-cli
后,我运行此命令以使用打字稿模板启动 RN 项目:
npx react-native init MyApp --template react-native-template-typescript
但我收到了这个错误:
警告 jest > jest-cli > jest-config > jest-environment-jsdom > jsdom
left-pad@1.3.0: use String.prototype.padStart() error 发生意外错误:“ https://registry.yarnpkg.com/react-native-template-react-native-template-typescript : Not found” .info 如果您认为这是一个错误,请打开…..
[1⁄2] 移除模块 react-native-template-react-native-template-typescript…
错误 此模块未在 package.json 文件中指定。
info 访问 https://yarnpkg.com/en/docs/cli/remove 以获取有关此命令的文档。警告无法清理 node_modules/react-native-template-react-native-template-typescript 中的模板临时文件。这不是严重错误,您可以在您的应用程序上工作。
(节点:8548)UnhandledPromiseRejectionWarning:错误:命令失败:yarn add react-native-template-react-native-template-typescript
原文由 Yacine 发布,翻译遵循 CC BY-SA 4.0 许可协议
已解决:我也必须使用 yarn 删除 react native cli