How do I create an Expo app when it keeps giving this error?

Viewed 41

Tried every possible step

  • Reinstalled Node, NPM, Expo, etc.
  • Cleaned Cache, verified it aswell.
  • Please help or I would have to reinstall Ubuntu.
faisal@PC:~$ expo init

Migrate to using:
› npx create-expo-app --template

✔ What would you like to name your app? … my-app
✔ Choose a template: › blank               a minimal app as clean as an empty canvas
Error downloading and extracting template package: TypeError: Cannot read properties of null (reading '0')
✖ Something went wrong while downloading and extracting the template.

Can't read JSON file: /home/faisal/my-app/app.json
└─ Cause: Error: ENOENT: no such file or directory, open '/home/faisal/my-app/app.json'
    ├─ readAsync /usr/local/lib/node_modules/expo-cli/node_modules/@expo/json-file/src/JsonFile.ts:158:13
    ├─ extractAndPrepareTemplateAppAsync /usr/local/lib/node_modules/expo-cli/src/commands/utils/extractTemplateAppAsync.ts:25:25
    └─ actionAsync /usr/local/lib/node_modules/expo-cli/src/commands/initAsync.ts:290:19
faisal@PC:~$ npx create-expo-app myapp
✖ Something went wrong in downloading and extracting the project files: Could not find npm package "expo-template-blank@latest"
Error cloning template: Error: Could not find npm package "expo-template-blank@latest"
faisal@PC:~$ npm ls -g
/usr/local/lib
+-- @angular/cli@14.2.3
+-- expo-cli@6.0.5
+-- expo-template-blank@46.0.21
`-- npm@8.19.2

faisal@PC:~$ npm -v
8.19.2
2 Answers

If you previously installed a global react-native-cli package, please remove it as it may cause unexpected issues:

Run this command npm uninstall -g react-native-cli @react-native-community/cli

Start a new project npx react-native init AwesomeProject

Reinstalled Node using NVM

Apparently the node I installed multiple times through the store was giving the error so I decided to use the Node Version Manager instead.

Instructions:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
source ~/.bashrc
nvm list-remote
nvm install v16.17.1

And yes, it works:

faisal@pc:~$ nvm install v16.17.1
Downloading and installing node v16.17.1...
Downloading https://nodejs.org/dist/v16.17.1/node-v16.17.1-linux-x64.tar.xz...
######################################################################################################################################################################### 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v16.17.1 (npm v8.15.0)
Creating default alias: default -> v16.17.1
faisal@pc:~$ expo init

Migrate to using:
› npx create-expo-app --template

✔ What would you like to name your app? … my-app
✔ Choose a template: › blank               a minimal app as clean as an empty canvas
✔ Downloaded template.
 Using npm to install packages.
✔ Installed JavaScript dependencies.

✅ Your project is ready!

To run your project, navigate to the directory and run one of the following npm commands.

- cd my-app
- npm start # you can open iOS, Android, or web from here, or run them directly with the commands below.
- npm run android
- npm run ios # requires an iOS device or macOS for access to an iOS simulator
- npm run web
Related