expo / expo-cli

Tools for creating, running, and deploying universal Expo and React Native apps
https://docs.expo.io/workflow/expo-cli/
2.61k stars 477 forks source link

expo-cli i error #1133

Closed jnaguib closed 4 years ago

jnaguib commented 5 years ago

Description

I am trying to create a new expo project using the non-interactive flag but I keep getting Can't read JSON file /app.json

Expected Behavior

I ran: expo-cli i --template blank --name testApp --yarn --non-interactive ./testApp

Expecting: to create a new expo application with the application name testApp.

Observed Behavior

This is what's created inside testApp folder:

README.md blank.js bower.json package.json tests tests.js

./tests: assert.js main.js

No app.json file is created

That's the output of the terminal:

[17:27:37] Extracting project files...
[17:27:37] Customizing project...
[17:27:37] Can't read JSON file: /Users/john/Desktop/testApp/app.json
└─ Cause: Error: ENOENT: no such file or directory, open '/Users/john/Desktop/testApp/app.json'
[17:27:37] JsonFileError: Can't read JSON file: /Users/john/Desktop/testApp/app.json
└─ Cause: Error: ENOENT: no such file or directory, open '/Users/john/Desktop/testApp/app.json'
    at /Users/john/.config/yarn/global/node_modules/@expo/json-file/src/JsonFile.ts:158:13
    at Generator.throw (<anonymous>)
    at rejected (/Users/john/.config/yarn/global/node_modules/@expo/json-file/build/JsonFile.js:5:65)

Environment

Expo CLI 3.4.0 environment info: System: OS: macOS 10.14.6 Shell: 3.2.57 - /bin/bash Binaries: Node: 10.16.3 - /usr/local/bin/node Yarn: 1.19.1 - ~/.yarn/bin/yarn npm: 6.9.0 - /usr/local/bin/npm IDEs: Android Studio: 3.5 AI-191.8026.42.35.5791312 Xcode: 11.0/11A420a - /usr/bin/xcodebuild npmGlobalPackages: expo-cli: 3.4.0

fson commented 5 years ago

This is really weird, looks the command downloads a package named blank from npm and extracts it, when it should download expo-template-blank (--template blank is an alias for --template expo-template-blank).

I was not able to reproduce this yet, for me it downloaded the right template package. Could you check, if this also happens with --template tabs?

fson commented 5 years ago

In the meantime, you should be able to initialize an app using the blank template by specifying the full name of the template, --template expo-template-blank.

jnaguib commented 5 years ago

Thank you @fson it worked with --template expo-tmeplate-blank. And I did try it with --template tabs and it did the same thing as blank. Couldn't find app.json and got tabs.js

byCedric commented 5 years ago

I can reproduce it, used Docker as environment on a Linux machine:

$ docker run -ti --rm -w /code/test bycedric/expo-cli \
    expo init . --template blank --name test --yarn --non-interactive
> [22:19:30] Extracting project files...
> [22:19:30] Customizing project...
> [22:19:30] Can't read JSON file: /code/test/app.json
> └─ Cause: Error: ENOENT: no such file or directory, open '/code/test/app.json'

I'll try to create a PR if I found the issue 😄