Reputation: 1
Error downloading and extracting template package: Error: Could not parse JSON returned from "npm pack expo-template-blank --dry-run"
I intend to create a project with exfo using a template, either from blank or template typescript
Upvotes: 0
Views: 43
Reputation: 1
When you encounter an error while trying to initialize an Expo project with a template, it typically points to issues with the npm package fetching process. Here are the steps to troubleshoot and resolve this issue:
Check Node.js and npm Versions: Ensure that you have the latest stable versions of Node.js and npm installed.
node -v
npm -v
You can update Node.js and npm if needed.
Clear npm Cache: Sometimes, cached files can cause issues. Clearing the npm cache can help.
npm cache clean --force
Update npm: Ensure that npm is up to date.
npm install -g npm
Install expo-cli:
Make sure you have the latest version of expo-cli
installed.
npm install -g expo-cli
Initialize the Expo Project: Try creating a new project again. Use the following commands depending on the template you want:
For a blank template:
expo init MyNewProject
For a TypeScript template:
expo init MyNewProject --template expo-template-blank-typescript
Check npm Registry: Ensure that the npm registry is set correctly and that you are not behind a proxy that might be blocking access.
npm config get registry
The default should be https://registry.npmjs.org/
. If it’s different, set it back to default:
npm config set registry https://registry.npmjs.org/
Manual Installation: If the above steps do not work, you can try to install the template manually and then create the project:
npm pack expo-template-blank
tar -xzf expo-template-blank-*.tgz
Then move the contents of the extracted directory to your project directory.
Creating a Project Directory:
mkdir MyNewProject
cd MyNewProject
Initialize with expo-cli:
expo init --template expo-template-blank
Alternative: Clone the Template Repository Directly:
If all else fails, you can directly clone the template repository from GitHub and set it up manually.
git clone https://github.com/expo/expo-template-blank MyNewProject
cd MyNewProject
npm install
expo diagnostics
to get more information about your environment, which may help in troubleshooting further.Following these steps should help you resolve the issue and get your Expo project initialized successfully.
Upvotes: 0
Reputation: 31
If you want to initialise your project with a template typescript you should go with the:
npx create-expo-app <project_name> --template expo-template-blank-typescript
Hope it helps
Upvotes: 0