skip to Main Content

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

2

Answers


  1. 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

    Login or Signup to reply.
  2. 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:

    Step-by-Step Guide:

    1. 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.

    2. Clear npm Cache:
      Sometimes, cached files can cause issues. Clearing the npm cache can help.

      npm cache clean --force
      
    3. Update npm:
      Ensure that npm is up to date.

      npm install -g npm
      
    4. Install expo-cli:
      Make sure you have the latest version of expo-cli installed.

      npm install -g expo-cli
      
    5. 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
      
    6. 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/
      
    7. 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.

    Example of Creating a Project with the Template

    1. Creating a Project Directory:

      mkdir MyNewProject
      cd MyNewProject
      
    2. Initialize with expo-cli:

      expo init --template expo-template-blank
      
    3. 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
      

    Additional Tips:

    • Network Issues: Ensure your internet connection is stable.
    • Permissions: Run the terminal or command prompt as an administrator.
    • Expo Diagnostics: If issues persist, you can use 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search