I have moved my package.json file one folder up in react project and now `npm start` is not working

Viewed 156

my current folder structure is

   -- project folder
         |-- package.json
         |-- react-project
                  |-- src folder
                  |-- public folder

My node version is 18

1 Answers

In order for npm start to work, you have to run the command from the same directory as your package.json.

node_modules, package-lock.json, and package.json should always be at the root of the project as a good practice.

If you move these files/folders it can disrupt the pathing of them.

For example, inside package.json at the top you will a line somewhat like: "main": "node_modules/expo/AppEntry.js". If you move node_modules or package.json, then this will no longer work. It would need to be changed to something like, "./node_modules" or "../node_modules"

If there is a specific reason you need to move this folder, then you will have to do some reconfiguring to ensure the pathing is correct.

Related