简体   繁体   中英

React Js : no such file or directory, open Package.json

While running npm start, I am getting error -

PS D:\React\operations_app_tut> npm start

npm ERR! path D:\React\operations_app_tut\package.json
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open 'D:\React\operations_app_tut\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\IT-DI\AppData\Roaming\npm-cache\_logs\2020-12-16T05_56_02_304Z-debug.log

While checking physical path made sure file exists -

在此处输入图像描述

Structure Of Project For Ref -

在此处输入图像描述

I referred few sites and again ran -npm install But same error persisted.

You are running npm start in incorrect folder.Also why there is package-lock.json outside.

move to D:\React\operations_app_tut\operations_app_tut directory then run npm start

Thanks @NitinDev And @Adithya.

Adding details if future contributor faces the same issue -

My mistake here was, I had a folder D:/React Within this folder I had all my react projects. I manually created - operations_app_tut folder in D:/React

After this I opened it through Visual Code via path:- D:/React/operations_app_tut and ran command -

npx create-react-app operations_app_tut

This command created another folder within operations_app_tut which made my project path to be - D:/React/operations_app_tut/operations_app_tut

Since I was running npm start on terminal with path - D:/React/operations_app_tut which was not the actual path, it was giving me error.

Lesson -

  1. Do not create Project Folder Manually, it will automatically get created via npx create-react-app

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