Creating project with TypeScript template fails with errors in the log
Environment
-
react-native -v: react-native-cli: 2.0.1 -
react-native run-windows --info:
System: OS: Windows 10 10.0.18363 CPU: (12) x64 Intel(R) Xeon(R) W-2133 CPU @ 3.60GHz Memory: 10.20 GB / 31.66 GB Binaries: Node: 12.13.1 - C:\Program Files\nodejs\node.EXE Yarn: 1.19.2 - C:\Program Files (x86)\Yarn\bin\yarn.CMD npm: 6.13.1 - C:\Program Files\nodejs\npm.CMD npmPackages: react: 16.8.6 => 16.8.6 react-native: ^0.60.0 => 0.60.6 react-native-windows: 0.60.0-vnext.86 => 0.60.0-vnext.86 rnpm-plugin-windows: ^0.3.8 => 0.3.8 Installed UWP SDKs: 10.0.14393.0 10.0.15063.0 10.0.16299.0 10.0.17106.0 10.0.17749.0 10.0.17763.0 10.0.18362.0
This issue very easy to reproduce. I just ran the following command to create an new project with the --template as TypeScript. It created the project successfully and reported the following error. However, the project ended being JavaScript template instead of TypeScript. Please refer to the log below.
Command Executed:
react-native init SimpleApp2 --version 0.60.6 --template TypeScript
Error reported for the type script template
yarn add v1.19.2 [1/4] Resolving packages... warning jest > jest-cli > jest-config > jest-environment-jsdom > jsdom > [email protected]: use String.prototype.padStart() error An unexpected error occurred: "https://registry.yarnpkg.com/react-native-template-TypeScript: Not found". info If you think this is a bug, please open a bug report with the information provided in "D:\dev\play\react-native\SimpleApp2\yarn-error.log". info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command. yarn remove v1.19.2 [1/2] Removing module 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-TypeScript. This is not a critical error, you can work on your app. (node:5788) UnhandledPromiseRejectionWarning: Error: Command failed: yarn add react-native-template-TypeScript at makeError (D:\dev\play\react-native\SimpleApp2\node_modules\execa\index.js:174:9) at D:\dev\play\react-native\SimpleApp2\node_modules\execa\index.js:278:16 at processTicksAndRejections (internal/process/task_queues.js:93:5) at async createFromRemoteTemplate (D:\dev\play\react-native\SimpleApp2\node_modules@react-native-community\cli\build\tools\generator\templates.js:118:5) at async createProjectFromTemplate (D:\dev\play\react-native\SimpleApp2\node_modules@react-native-community\cli\build\tools\generator\templates.js:91:3) at async generateProject (D:\dev\play\react-native\SimpleApp2\node_modules@react-native-community\cli\build\commands\init\initCompat.js:118:3) at async Object.initCompat [as init] (D:\dev\play\react-native\SimpleApp2\node_modules@react-native-community\cli\build\commands\init\initCompat.js:104:3) (node:5788) 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:5788) [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.
@rtselvan - It appears that react-native-template-Typescript has a special instruction when using against version 0.60. Please refer to these instructions - Typescript CLI.