node.jsnpm

What to do with two package.json files in a react project


Simple issue I have a folder where i created a react application via node.js and npm. As normal the creation of the react app also created a package.json and a package-lock.json file. A while after i installed react router dom now i have a second package.json and package-lock.json file a folder above my project.

Should i just leave this as it is, is there a way to merge these, can this cause any errors? Image of the Folders and files


Solution

  • You probably ran npm install a directory above instead of running it into the project directory itself.

    If there's only one package and that is react-router in the package.json newly created, I recommend deleting them and installing the package again in the frontend project directory.