React Application npm start is giving an error - node.js

I am trying to run my React app in the local environment and keep getting the following error
PS npm start
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:\Documents\business-website-react-master\package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'C:\\Documents\business-website-react-master\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:\\_logs\2020-02-22T20_12_59_502Z-debug.log
Here is what the folder directory looks like as well.
the package.json file is still there so i don't understand why the file cannot be located.
Thank you in advance!

As the error message states, npm does not find package.json file. The reason in your case is that the file is located in the src folder. Once you move the file into the root - where you tried to run earlier - and run npm start then it should be just starting fine.
If the node_modules folder is also missing - which is containing all the installed dependencies to run your project - then you need to run first npm install which will take all the dependencies from package.json and install them.
I hope that helps!

Related

how to fix npm error in Mac in visual studio code

How do I fix this error?
USER#Bahus-MacBook-Air metaplex-master % npm --version
8\.5.2
USER#Bahus-MacBook-Air metaplex-master % npm install
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /Users/USER/Desktop/solana devnet/metaplex-master/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/Users/USER/Desktop/solana devnet/metaplex-master/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! /Users/USER/.npm/\_logs/2022-03-24T13_07_17_630Z-debug-0.log
How do I fix this npm installation error in visual studio code in Mac?
The error message says that the path where you are executing npm i command doesn't have package.json file.
Make sure to change the path to the place where the package.json file is located.
I'm assuming you are trying this project https://github.com/metaplex-foundation/metaplex
And you are probably running npm install in the main directory. But if you read the instalation documentation which you definitely should, then you would see cd metaplex/js which means you need to run npm install within the ./js folder since that's where the package.json is, which is required by npm install command.

How can I fix npm error running npm run build?

When I run npm run build, I had this error and I couldn't fix it reading all articles on github and same quest-s on stack:
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:\Users\Користувач\Desktop\test/package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\Користувач\Desktop\test\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\Користувач\AppData\Local\npm-cache\_logs\2022-02-06T18_36_44_973Z-debug-0.log
Hi you are trying to run the build command in non node project please check whether you are in correct directory or not, if not please initialize the project by running npm init
ensure you're in the correct directory. You need to cd into the right directory before running the command.
If you want to make sure package.json is there in the directory, run
ls | grep package.json
if this doesn't show the file, then either you're in the wrong directory or you might have deleted package.json in which case you might have to recreate it, or bring it back from version control.

How to resolve the error while running react project?

I am getting an error while trying to run the react project using npm start. I have tried to reinstall npm modules and check but it is not working. It gives error as below:
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:\Users\91720\Desktop\React js/package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\91720\Desktop\React js\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\91720\AppData\Local\npm-cache_logs\2021-08-30T14_01_45_332Z-debug.log
Follow the steps below, if you've deleted your package.json file in your project.
Create a react application again using npx create-react-app {app-name} in a different folder. Then move to that folder (cd {app-name}) and check whether package.json file does exist.
Copy all the files you've created previously into /src folder of the newly created app.
If you already have the dependencies you used in previously created app, then copy it in dependency section of package.json file of newly created app.
Run npm install in application directory.
Check whether npm modules are created again.
If it installed perfectly, then run npm start to check whether application starts.
npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\91720\AppData\Local\npm-cache_logs\2021-08-30T14_01_45_332Z-debug.log
This error is because you are not in the current directory
TYPE cd{app-name}
Then npm start

Stuck on this error code ENOENT: no such file or directory, after trying to run "Hello World" exercise

I'm having some trouble trying to run the "Hello World" exercise from the PluralSight tutorial. I'm new to coding and I don't know what I'm doing wrong. I keep running into this error after entering the "npm run start" command in the terminal.
I looked up possible solutions online, but they all range from deleting and reinstalling the package.json file to reinstalling git and node.js, etc. I should note that I'm working on a Mac, so I don't know if that's also part of the issue or something.
Here's the code
charlierodriguez#Charlies-Mac-mini ~ % npm run start
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /Users/charlierodriguez/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/Users/charlierodriguez/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! /Users/charlierodriguez/.npm/_logs/2020-11-23T17_59_28_824Z-debug.log
charlierodriguez#Charlies-Mac-mini ~ %
This error comes when npm is finding package.json file in that location and not able to find it. Can you run js npm init. It will create package.json file in that location.
You will still get some different error. As there should be a key start in script segment in package.json file.
You can add that key with the value as command you want to run.

npm run serve failed

When I try to run "npm run serve" in my terminal on my Mac. I get following error message. It works fine for a couple a hours ago, but not now. can anyone help me?
npm ERR! syscall open
npm ERR! path /Users/MYNAME/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/Users/MYNAME/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! /Users/MYNAME/.npm/_logs/2020-09-03T12_46_01_362Z-debug.log
First check on your filesystem if the file EXISTS.
for a new project, you always need to create a package.json, running
npm init
will create a package.json for you in the current directory.
if you want to instantly create a package.jsn using defaults, run
npm init -y
for more understanding refer this npm guide
If you say that everything worked before, then you are running this script in the wrong folder and npm cannot find package.json.
no such file or directory, open '/Users/MYNAME/package.json'
Use the correct folder.

Resources