简体   繁体   中英

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

my current folder structure is

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

My node version is 18

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM