C Sharper
C Sharper

Reputation: 8626

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 -

enter image description here

Structure Of Project For Ref -

enter image description here

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

Upvotes: 2

Views: 12837

Answers (3)

Yvialga
Yvialga

Reputation: 35

To answer to your own explanation of your problem. Personally, I used npx create-next-app@latest (Next) so my project was create automatically but I had the same error : npm ERR! enoent Could not read package.json: Error: ENOENT: no such file or directory If I've understood correctly, you need to run your command npm start (or npm run dev with next) in the folder where the package.json file is located.

Upvotes: 0

C Sharper
C Sharper

Reputation: 8626

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

Upvotes: 1

Nitin Dev
Nitin Dev

Reputation: 119

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

Upvotes: 7

Related Questions