Skip to content

You can now use the new CLI to create a project 🎉 : npx react-native init MyApp --template react-native-template-typescript@next #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
NeilMcGuiness opened this issue Aug 20, 2019 · 12 comments
Labels
enhancement New feature or request

Comments

@NeilMcGuiness
Copy link

You can now use the new CLI to create a project 🎉 : npx react-native init MyApp --template react-native-template-typescript@next

Originally posted by @emin93 in #38 (comment)

@NeilMcGuiness
Copy link
Author

Expected Behavior

The project would initialize correctly after following the instructions described here

Observed Behavior

I am running into the same issues as #38 and #52 and for whatever reason, the 'fix' in #38 isn't working for me.

Reproducible Error

√ Downloading template
× Copying template
error Error: Cannot find module 'C:\Users\nmgs\AppData\Local\Temp\rncli-init-template-JZ9vNY\node_modules\typescript\template.config'
Require stack:
- C:\Users\nmgs\scoop\persist\yarn\global\node_modules\react-native\node_modules\@react-native-community\cli\build\commands\init\template.js
- C:\Users\nmgs\scoop\persist\yarn\global\node_modules\react-native\node_modules\@react-native-community\cli\build\commands\init\init.js
- C:\Users\nmgs\scoop\persist\yarn\global\node_modules\react-native\node_modules\@react-native-community\cli\build\commands\init\index.js
- C:\Users\nmgs\scoop\persist\yarn\global\node_modules\react-native\node_modules\@react-native-community\cli\build\commands\index.js
- C:\Users\nmgs\scoop\persist\yarn\global\node_modules\react-native\node_modules\@react-native-community\cli\build\cliEntry.js
- C:\Users\nmgs\scoop\persist\yarn\global\node_modules\react-native\node_modules\@react-native-community\cli\build\index.js
- C:\Users\nmgs\scoop\persist\yarn\global\node_modules\react-native\cli.js

Environment info

React native info output:

System:
    OS: Windows 10
    CPU: (4) x64 Intel(R) Core(TM) i7-7600U CPU @ 2.80GHz
    Memory: 7.94 GB / 15.89 GB
  Binaries:
    Node: 12.8.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.17.3 - C:\Users\nmgs\scoop\apps\yarn\current\Yarn\bin\yarn.CMD
    npm: 6.10.2 - C:\Program Files\nodejs\npm.CMD
  IDEs:
    Android Studio: Version  3.4.0.0 AI-183.6156.11.34.5692245

react-native: 0.60.5

^ This is what it says in package.json.

Strangely enough when i run:
react-native --version
It returns nothing.

Steps To Reproduce

  1. Install the latest version of react-native-cli

I have tried both:

npm install -g react-native-cli

AND

yarn global add @react-native-community/[email protected]

Try to create a project using either the getting started method of:

react-native init ProjectName

OR the fix posted by @emin93 (referenced at the head of the issue) :

npx react-native init MyApp --template react-native-template-typescript@next

@MateusAndrade MateusAndrade added the enhancement New feature or request label Sep 9, 2019
@radko93
Copy link
Collaborator

radko93 commented Sep 10, 2019

Hi, this is now fixed in #59, if you still encounter this problem I will reopen this. Please use the fix for now.

@radko93 radko93 closed this as completed Sep 10, 2019
@Yashas0796
Copy link

Hi, I have used the following command:
npx react-native init MyApp2 --template react-native-template-typescript@next after
npm install -g react-native-cli but still am getting the same issue

√ Downloading template
× Copying template
error Error: Cannot find module 'C:\Users\YASHAS~1.B\AppData\Local\Temp\rncli-init-template-tMgd3Y\node_modules\react-native-template-typescript\template.config'
Require stack:

  • C:\Users\yashaswini.b\node_modules\react-native\node_modules@react-native-community\cli\build\commands\init\template.js
  • C:\Users\yashaswini.b\node_modules\react-native\node_modules@react-native-community\cli\build\commands\init\init.js
  • C:\Users\yashaswini.b\node_modules\react-native\node_modules@react-native-community\cli\build\commands\init\index.js
  • C:\Users\yashaswini.b\node_modules\react-native\node_modules@react-native-community\cli\build\commands\index.js
  • C:\Users\yashaswini.b\node_modules\react-native\node_modules@react-native-community\cli\build\cliEntry.js
  • C:\Users\yashaswini.b\node_modules\react-native\node_modules@react-native-community\cli\build\index.js
  • C:\Users\yashaswini.b\node_modules\react-native\cli.js

@radko93
Copy link
Collaborator

radko93 commented Sep 13, 2019

@Yashas0796 You have to uninstall react-native-cli, you don't need it.

@roybarman
Copy link

roybarman commented Sep 17, 2019

I had the exact same issue as @Yashas0796 . The following exact commands (in this following order) resolved it.
$ npm uninstall -g react-native-cli
$ npm install -g react-native-cli
$ react-native init MyApp

@radko93
Copy link
Collaborator

radko93 commented Sep 19, 2019

@roybarman please don't do npm install -g react-native-cli, it does not make any sense now

@puertadavid
Copy link

I had the same problem and i change the project path from the disk C to D, it seems like the problem is that i tried to install in the desktop and there is any problem.

@Davenporten
Copy link

I'm running into this issue of when I run
npx react-native init TestProject
I have been trying everything people are been mentioning here and in other places and am not finding a solution.

√ Downloading template
× Copying template
error Error: Cannot find module 'C:\Users<NAME>\AppData\Local\Temp\rncli-init-template-BXWSTp\node_modules\react-native\template.config'
Require stack:
- C:\Users<NAME>\node_modules\react-native\node_modules@react-native-community\cli\build\commands\init\template.js
- C:\Users<NAME>\node_modules\react-native\node_modules@react-native-community\cli\build\commands\init\init.js
- C:\Users<NAME>\node_modules\react-native\node_modules@react-native-community\cli\build\commands\init\index.js
- C:\Users<NAME>\node_modules\react-native\node_modules@react-native-community\cli\build\commands\index.js
- C:\Users<NAME>\node_modules\react-native\node_modules@react-native-community\cli\build\index.js
- C:\Users<NAME>\node_modules\react-native\cli.js

@GameBatta
Copy link

Any solution for this issue. It seems its trying to download templates to C:\Users{userName}\AppData\Local\Temp\rncli-init-template-XXXXXX, but within that folder, I can't see anything. After a second it had been removed. So it says cant find the template...

@vanlethi
Copy link

I had the exact same issue as @Yashas0796 . The following exact commands (in this following order) resolved it.
$ npm uninstall -g react-native-cli
$ npm install -g react-native-cli
$ react-native init MyApp

thanks, I followed commands and it done well.

@ExitTrance
Copy link

ExitTrance commented Dec 19, 2019

Any solution for this issue. It seems its trying to download templates to C:\Users{userName}\AppData\Local\Temp\rncli-init-template-XXXXXX, but within that folder, I can't see anything. After a second it had been removed. So it says cant find the template...

I think I found a solution that works for me while only using npx (as globally installing it seems to be something not advised by the dev team). You have to use either CMD, or Powershell + running the following command Set-ExecutionPolicy RemoteSigned (thanks to this post). I have tried both with only admin rights, so if it doesn't work, make sure to start them up as admin! Do go to that stackoverflow post to read up on it, as it is an interesting topic and in your best interest to know what the command does, before actually running it.

If it doesn't work even after adjusting with this, I could post my Node and npm version here and see if that might have something to do with it?

Anyway, I tried to create a regular, and typescript project both in PS and cmd, and they worked fine with the following commands once I adjusted for the above:

npx react-native init MyApp
npx react-native init AwesomeTSProject --template react-native-template-typescript

Extra Info:

This came about thanks to having the 'cannot find module' error, and trying to install yarn (after trying out everything to not have to install stuff via npm globally), and finding out that I am not able to run scripts even on an admin powershell (been only trying it out on Powershell!!).

yarn : File C:\Program Files\nodejs\yarn.ps1 cannot be loaded because running scripts is disabled on this system.   For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1

@Gourab-hub
Copy link

error showing in my cmd: what can i do

Microsoft Windows [Version 10.0.18363.900]
(c) 2019 Microsoft Corporation. All rights reserved.

C:\Users\Gourab Banik\Desktop\New folder>npx react-native init MyTestApp
Error: EPERM: operation not permitted, mkdir 'C:\Users\Gourab'
TypeError: Cannot read property 'get' of undefined
at errorMessage (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-message.js:38:39)
at errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:201:13)
at C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js:78:20
at cb (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:225:22)
at C:\Program Files\nodejs\node_modules\npm\lib\npm.js:263:24
at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:81:7
at Array.forEach ()
at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:80:13
at f (C:\Program Files\nodejs\node_modules\npm\node_modules\once\once.js:25:25)
at afterExtras (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:171:20)
C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:97
var doExit = npm.config.loaded ? npm.config.get('_exit') : true
^

TypeError: Cannot read property 'loaded' of undefined
at exit (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:97:27)
at process.errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:216:3)
at process.emit (events.js:311:20)
at process._fatalException (internal/process/execution.js:164:25)
Install for [ 'react-native@latest' ] failed with code 7

C:\Users\Gourab Banik\Desktop\New folder>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests