Cli: ERROR: cannot find module : template.config

Created on 21 Nov 2019  Â·  21Comments  Â·  Source: react-native-community/cli

After running "npx react-native init MyApp --template react-native-template-ui-kitten"

I am presented with an error.

× Copying template
error Error: Cannot find module 'C:\Users\kylef\AppData\Local\Temp\rncli-init-template-Qq6OrG\node_modules\react-native\template.config'
Require stack:

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

I am running VS Code latest on windows

bug report windows

Most helpful comment

Im Using Win 10 Pro

I just fix that error using:

open CMD,

yarn global add react-native-cli

then

react-native init yourProject

All 21 comments

Looking at the repo here: https://github.com/akveo/react-native-ui-kitten, there's no template.config.js which is mandatory for init to work.

However, seeing the error message is ugly, I'd be happy if you'd like to contribute a better one. Something like this would do:

Couldn't find "template.config.js" file, which is mandatory for a custom React Native template "react-native-template-ui-kitten". Please make sure you use correct version of the template and contact its maintainers if necessary. Docs: https://github.com/react-native-community/cli/blob/master/docs/init.md#creating-custom-template

Hi @thymikee thank you for your response.

I have already spoken with react-native-template-ui-kittens team and they say they were unable to replicate the issue.

I then tried running npx react-native init MyApp, I was presented with the same issue.

Is this an issue on my side? How would one go about fixing it? I have tried uninstalling react and reinstalling it. I have updated it a few times and I currently don't know how to resolve the issue.

Thank you in advance

@thymikee the problem is that we have template.config - https://github.com/akveo/react-native-ui-kitten/tree/master/src/templates/template-ui-kitten

And running both Mac and win10 I was not able to reproduce it

Oh, I see, so the template is fine. Can you show output of npx react-native --version? Make sure to uninstall global react-native-cli and react-native if you have such.

Yes, as a maintainer I have the latest versions (I have @react-native-community/cli installed globally). However, I'm not able to reproduce this running both npx react-native init blah and npx @react-native-community/cli init blah

UPD

➜ npx react-native --version
3.0.4

For any reason, this still occurs for reporter even after running this command, as I suggested here

Hi @artyorsh @thymikee
I am still running into the issue. Does anybody have any suggestions for a fix?
I am unable to replicate anything without running into an issue.
When I run
npx react-native init MyApp

I get

√ Downloading template
× Copying template
error Error: Cannot find module 'C:\Users\kylef\AppData\Local\Temp\rncli-init-template-fG941s\node_modulesreact-native\template.config'
Require stack:

  • C:\Users\kylef\node_modules\@react-native-community\cli\build\commands\init\template.js
  • C:\Users\kylef\node_modules\@react-native-community\cli\build\commands\init\init.js
  • C:\Users\kylef\node_modules\@react-native-community\cli\build\commands\init\index.js
  • C:\Users\kylef\node_modules\@react-native-community\cli\build\commands\index.js
  • C:\Users\kylef\node_modules\@react-native-community\cli\build\index.js
  • C:\Users\kylef\node_modulesreact-native\cli.js
    PS C:\Users\kylef\Desktop\App\Expo-app> npx react-native --version
    3.0.4
    PS C:\Users\kylef\Desktop\App\Expo-app>

Thanks @artyorsh. The question was for @Work90210 because his environment is an issue.

@thymikee I am running react-native v3.0.4

Oh, I see, so the template is fine. Can you show output of npx react-native --version? Make sure to uninstall global react-native-cli and react-native if you have such.

To confirm, it is npm un -g react-native to uninstall?

Yes

when i run npm un -g react-native
I get

up to date in 0.024s

I am also seeing this issue. I have made sure i have uninstalled globals of react-native and react-native-cli by running

npm un -g react-native
npm un -g react-native-cli

I have updated to the latest node and npm

$ node --version
v12.16.0

$ npm -v
6.13.7

The only way I can successfully create a new bare app is to install "react-native-cli" globally. But the docs say you shouldn't install globally (as well as stackoverflow comments to other issues I have seen)

I'm having the same problem. Running on Windows 10.
I confirmed react-native is not installed globally:

$ npm uninstall -g react-native
$ react-native --version
'react-native' is not recognized as an internal or external command,
operable program or batch file.

Then, when running npx react-native init myApp I got:

√ Downloading template
× Copying template
error Error: Couldn't find the "C:\Users\Ori\AppData\Local\Temp\rncli-init-template-81lnDJ\node_modules\react-native\template.config.js file inside "react-native" template. Please make sure the template is valid. Read more: https://github.com/react-native-community/cli/blob/master/docs/init.md#creating-custom-template

Maybe it's worth mentioning that after running npx react-native init I do have RN installed globaly:

$ react-native --version
3.1.0

Is there a solution i have the same issue, maybe the native templates are broken?

Same problem

Try removing any node_modules folders and/or package.json files you may have in the folder you're trying to run init in.

Error: Couldn't find the "C:\Users\ADMINI~1\AppData\Local\Temp\rncli-init-template-LnsCSY\node_modulesreact-nativetemplate.config.js file inside "react-native" template.So how can i resolve this problem?

Im Using Win 10 Pro

I just fix that error using:

open CMD,

yarn global add react-native-cli

then

react-native init yourProject

Running CMD/Powershell as admin on Windows fixed this issue for me.

Was this page helpful?
0 / 5 - 0 ratings