Cli: UnhandledPromiseRejectionWarning: Error: Command failed: yarn add react-native-template-react-native-template-typescript

Created on 17 Jul 2020  路  6Comments  路  Source: react-native-community/cli

ref https://github.com/facebook/react-native/issues/29411

Description

I am trying to start a new project with typescript template and it's failing on the step Removing module react-native-template-react-native-template-typescript... with error error This module isn't specified in a package.json file., followed by this error UnhandledPromiseRejectionWarning: Error: Command failed: yarn add react-native-template-react-native-template-typescript.

This is the command I am running:
npx react-native init MyAwesomeApp --template react-native-template-typescript

React Native version:

0.63

Steps To Reproduce

  1. run npx react-native init MyAwesomeApp --template react-native-template-typescript
  2. watch it fails

Expected Results

Successfully creates a new RN project

Snack, code example, screenshot, or link to a repository:

Full stack trace:

[1/4] 馃攳  Resolving packages...
warning jest > @jest/core > jest-config > jest-environment-jsdom > jsdom > [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
error An unexpected error occurred: "https://registry.yarnpkg.com/react-native-template-react-native-template-typescript: Not found".
info If you think this is a bug, please open a bug report with the information provided in "/path/to/project/MyAwesomeApp/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
yarn remove v1.22.4
[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:68507) UnhandledPromiseRejectionWarning: Error: Command failed: yarn add react-native-template-react-native-template-typescript
    at makeError (/path/to/project/MyAwesomeApp/node_modules/execa/index.js:174:9)
    at /path/to/project/MyAwesomeApp/node_modules/execa/index.js:278:16
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async createFromRemoteTemplate (/path/to/project/MyAwesomeApp/node_modules/@react-native-community/cli/build/tools/generator/templates.js:115:5)
    at async createProjectFromTemplate (/path/to/project/MyAwesomeApp/node_modules/@react-native-community/cli/build/tools/generator/templates.js:88:3)
    at async generateProject (/path/to/project/MyAwesomeApp/node_modules/@react-native-community/cli/build/commands/init/initCompat.js:118:3)
    at async Object.initCompat (/path/to/project/MyAwesomeApp/node_modules/@react-native-community/cli/build/commands/init/initCompat.js:105:3)
(node:68507) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3)
(node:68507) [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.
bug report

Most helpful comment

You may have installed it by accident. Try npx [email protected] init or npx @react-native-community/cli init which will also work.

All 6 comments

Please use npx react-native init MyAwesomeApp --template typescript.

@jgcmarins @DevHabit it's apparent you have a globale react-native binary installed, (react-native-cli module), which you should remove. Please make sure to run npm uninstall -g remove react-native react-native-cli and same for Yarn. Check some older Node versions or caches. Running which react-native shouldn't return anything. Then you can run:

npx react-native init MyAwesomeApp --template react-native-template-typescript

as official RN docs advise: https://reactnative.dev/docs/typescript

@thymikee
I didn't install react-native-cli module globally.
I am using macOS Big Sur.
npx react-native init MyAwesomeApp --template react-native-template-typescript doesn't work.

You may have installed it by accident. Try npx [email protected] init or npx @react-native-community/cli init which will also work.

Thank you, @thymikee .
Eventually, I did npx @react-native-community/cli init MyAwesomeApp --template react-native-template-typescript.
It works.
But npx react-native init MyAwesomeApp --template react-native-template-typescript still doesn't work.

That's something with your environment that you have to fix unfortunately. Nothing we can do on our end really, if we want to keep this experience.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ctavan picture ctavan  路  3Comments

mauricioscotton picture mauricioscotton  路  3Comments

Jyrno42 picture Jyrno42  路  4Comments

owinter86 picture owinter86  路  3Comments

tallpants picture tallpants  路  4Comments