解决初始化TypeScript模板的RN项目报错问题
程序员文章站
2022-06-15 22:46:09
...
info Fetching template react-native-template-react-native-template-typescript...
yarn add v1.22.4
warning ../../../package.json: No license field
[1/4] ???? Resolving packages...
warning jest > jest-cli > jest-config > jest-environment-jsdom > jsdom > [email protected]: use String.prototype.padStart()
warning jest > jest-cli > jest-config > jest-environment-jsdom > jsdom > [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
error An unexpected error occurred: "https://registry.npm.taobao.org/react-native-template-react-native-template-typescript: ETIMEDOUT".
info If you think this is a bug, please open a bug report with the information provided in "/Users/*nsheng/Desktop/rn-works/RN_WanAndroid/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
yarn remove v1.22.4
warning ../../../package.json: No license field
[1/2] ???? Removing module react-native-template-react-native-template-typescript...
error This module isn't specified in a package.json file.
info Visit https://yarnpkg.com/en/docs/cli/remove for documentation about this command.
warn Failed to clean up template temp files in node_modules/react-native-template-react-native-template-typescript. This is not a critical error, you can work on your app.
(node:55771) UnhandledPromiseRejectionWarning: Error: Command failed: yarn add react-native-template-react-native-template-typescript
at makeError (/Users/*nsheng/Desktop/rn-works/RN_WanAndroid/node_modules/execa/index.js:174:9)
at /Users/*nsheng/Desktop/rn-works/RN_WanAndroid/node_modules/execa/index.js:278:16
at processTicksAndRejections (internal/process/task_queues.js:85:5)
(node:55771) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
(node:55771) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
解决方式:
1.删除旧版本 react-native-cli
npm uninstall -g react-native-cli
2.重新安装来自"react-native-community"的cli库 :
npm i -g @react-native-community/cli
3.重新初始化项目即可:
npx react-native init MyApp --template react-native-template-typescript
推荐阅读
-
解决在vue项目中,发版之后,背景图片报错,路径不对的问题
-
Xcode 10升级导致项目报错的常见问题解决
-
解决vue2.0动态绑定图片src属性值初始化时报错的问题
-
解决安装vs2019后原vs2017项目无法编译各种报错的问题
-
vue-cli webpack模板项目搭建及打包时路径问题的解决方法
-
快速解决vue-cli不能初始化webpack模板的问题
-
解决vue项目运行npm run serve报错的问题
-
spring boot项目导入依赖后代码报错问题的解决方法
-
解决vue项目运行出现warnings potentially fixable with the `--fix` option的报错问题
-
解决初始化TypeScript模板的RN项目报错问题