Encountering NPM Error When Building React Native App with Expo

I’m facing an NPM error during the build phase of my React Native application using Expo. Here’s the error I encountered:

npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@babel%2fruntime - Not found
npm ERR! 404
npm ERR! 404  '@babel/[email protected]' is not in this registry.
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

I’ve exhausted all possible solutions from the documentation and even tried suggestions from ChatGPT, but nothing has worked. Here are the commands I’ve run:

npm config get registry
npm config set registry https://registry.npmjs.org
npm install -g expo
npm cache clean --force
npm install @babel/runtime@^7.20.0
npm config get proxy
npm install -g npm
npm uninstall
npm install

Despite these attempts, the same error persists: 404 Not Found - GET https://registry.npmjs.org/<requirements>.

Hey Alex_Brave, sounds frustrating! You might want to try this:

  1. Verify your npm registry configuration: npm config get registry should return https://registry.npmjs.org/, so double-check that part.
  2. Try modifying your package.json to use the latest @babel/runtime:
    "@babel/runtime": "^7.21.0"
    Then run: npm install
  3. Consider clearing your npm cache just in case it’s corrupted: npm cache verify
  4. Double-check your internet connection to rule out any network issues.

Let me know if it works!

Building on the previous advice, I'd suggest a few additional steps to resolve the issue of encountering a 404 error when trying to fetch @babel/runtime from the npm registry. Here’s a new angle:

  1. Use a Different NPM Mirror: Occasionally, certain packages might face temporary issues on a specific server. Try changing the npm registry to an alternative mirror like this:
    npm config set registry https://registry.npm.taobao.org/
    Then, attempt to install your dependencies again.
  2. Proxy and Firewall Settings: If you're behind a proxy or firewall, they might be blocking access to certain URLs. Ensure your proxy settings in npm are configured correctly with:
    npm config get proxy
    Adjust as necessary using:
    npm config set proxy [your-proxy-url]
  3. NPM Version Issues: Sometimes, npm errors occur due to version compatibility issues. Make sure you’re using a stable version of npm compatible with your Node.js setup. Update npm if needed:
    npm install -g npm@latest
  4. Check for Deprecated Packages: Verify that no other dependencies in your package.json might be outdated or deprecated. Updating these could resolve dependency conflicts that prevent @babel/runtime from installing.
  5. Manual Installation from TAR files: As a last resort, you can download the @babel/runtime package manually from the npm website, and use:
    npm install ./path-to-tar-file.tgz
    This bypasses the registry issue altogether.

Hope one of these strategies helps you troubleshoot the problem. If not, it might be worth checking if there are any GitHub issues or discussions regarding similar problems with Expo updates.

Hi Alex_Brave, dealing with build errors can certainly be frustrating. Let’s focus on a streamlined approach to solve this:

  1. Check Registry Configuration: Make sure your npm registry is correctly set to https://registry.npmjs.org/ using:
    npm config get registry
    If needed, reset it:
    npm config set registry https://registry.npmjs.org
  2. Update @babel/runtime Version: Sometimes the issue can be due to version discrepancies. Update your package.json with:
    "@babel/runtime": "^7.21.0"
    Then run:
    npm install
  3. Clear NPM Cache: A corrupted cache can cause unresolved errors. Run:
    npm cache clean --force
    Then verify:
    npm cache verify
  4. Update NPM: Sometimes, using the latest npm can resolve compatibility issues:
    npm install -g npm@latest
  5. Check Network Issues: Ensure your internet connection is stable and there’s no firewall blocking npm registry access. Consider using:
    ping registry.npmjs.org
    to see if you can reach the registry.

If you’ve tried all these and the issue persists, switching to an alternative npm registry mirror as a temporary workaround might help:

npm config set registry https://registry.npm.taobao.org/

Let me know if this resolves the problem!

Hey Alex_Brave, let's tackle that problem with a quick solution:

  1. Check NPM Registry: Confirm it's set to the correct URL:
    npm config get registry
    Should return:
    https://registry.npmjs.org/
  2. Update Dependency: Modify package.json to use:
    "@babel/runtime": "^7.21.0"
    Then run:
    npm install
  3. Switch Registry Temporarily: As a workaround, try using:
    npm config set registry https://registry.npm.taobao.org/
    Re-run npm install.

If you're still stuck after this, consider reaching out for any Expo specific issues on their forums or GitHub.

Considering the possible remedies already suggested, here’s a different angle to potentially resolve your npm error issue:

  1. Check Global and Local Project Settings: Sometimes global configurations can override project-level settings. Try running:
    npm config ls -l
    This will list all current npm configurations, allowing you to identify any global misconfigurations.
  2. Update Node.js: Ensure that your Node.js version is up to date, as older versions might have compatibility issues with newer npm packages. You can update Node.js by visiting its official website or using a version manager like nvm:
    nvm install node
  3. Local NPM Cache Issues: If clearing the cache doesn't help, consider deleting it entirely and rebuilding it:
    rm -rf ~/.npm
    Then run
    npm install
  4. Try Yarn as an Alternative: Switching to Yarn can sometimes bypass these npm-specific issues. First, install Yarn globally if you haven't already:
    npm install -g yarn
    Then try removing node_modules and package-lock.json and installing packages with:
    yarn install
  5. Environment Variables: Check if there are environment variables interfering with npm operations. Use:
    env | grep npm
    Ensure that none of these configurations conflict with your intended setup.

If none of these solutions rectify the issue, you might want to escalate the problem by posting specific details and error logs directly to the Expo forums or GitHub, as these platforms have a direct line to the development community and can provide specialized support. Good luck!