How to reinstall dependencies after accidental 'npm uninstall'


I have a project generated using expo-cli & uses SDK 32.

So I happened to remove react-native-svg using npm uninstall during debugging, and now stuck on how to bring it back. (Before that I installed react-native-svg by accident when trying to setup react-native-fontawesome…)

Now react-native-svg can no longer be resolved:

Unable to resolve "react-native-svg" from "node_modules/@fortawesome/react-native-fontawesome/dist/converter.js"
Module 'react-native-svg' does not exist in the Haste module map

I have tried rm -rf node_modules && npm install to reinstall the whole project, but react-native-svg was not installed when I do this.
(I compared the result to another fresh inited project; in the fresh inited one react-native-svg is installed under node_modules directly, and everything works properly)

Do npm install react-native-svg --no-save by hand is also obviously not a solution (also, version is matched with the one in the fresh inited project):

Tried to register two views with the same name RNSVGPath

Question: is there a way to reinstall react-native-svg properly, so it’s just as installed through expo init?
(Otherwise I guess the final resort is to init the project again and move everything by hand…)

Can you just copy the node_modules from the fresh inited project to the node_modules of your actual project?

Nope, that wouldn’t work either.

  1. Deleting the whole node_modules & copy it from the fresh inited project, then npm install other packages I added by hand, results in this:
Unable to resolve "react-native-svg" from "node_modules/@fortawesome/react-native-fontawesome/dist/converter.js"
  1. cp -R only the react-native-svg folder from the fresh inited project node_modules gives this:
Tried to register two views with the same name RNSVGPath

You can not just copy the node Mods from the FD project to the node Mods of your actual [project] Im just wondering. I have law firms that have the same issue. I was checking out for my law firm to see what they were trying to do. None of my Attorneys could figure it out.

MyLaw firms and Attorneys have bad luck with this all the time!

Hey all, so I finally solved this :slight_smile:

An upgrade to SDK33 following this guide will solve the problem:

Seems all dependencies are correctly resolved during a npm install accompanies an SDK upgrade.

Also, upon reading this issue, looks like from SDK33 on, expo install would be another option to try out:

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.