2

I keep getting the npm ENOENT error when I try to run npm start. I'm not sure what to do to fix this issue.

I have tried to change permissions for folders.

bryantcaruthers-> npm start
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /Users/bryantcaruthers/workshop-vs-code-can-do-that/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/Users/bryantcaruthers/workshop-vs-code-can-do-that/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/bryantcaruthers/.npm/_logs/2019-11-06T03_31_38_233Z-debug.log

Be able to run npm start with no errors.

and here is my package json

{
  "name": "jobsportal",
  "version": "1.0.0",
  "description": "jobs api backend with node js",
  "main": "index.js",
  "scripts": {
    "start": "nodemon index.js"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "dotenv": "^16.3.2",
    "express": "^4.18.2",
    "mongoose": "^8.1.0",
    "nodemon": "^3.0.3"
  }
}

but when I try node index.js it works what is the problem?

1
  • Try running the npm install and then start the project by npm start Commented Nov 6, 2019 at 4:41

5 Answers 5

2

The error is that there is no package.json file in the directory you are running the code in:

no such file or directory, open /Users/bryantcaruthers/workshop-vs-code-can-do-that/package.json

Are you expecting a package.json file in that directory? Or should you be running npm start from somewhere else?

Sign up to request clarification or add additional context in comments.

Comments

1

You can resolve that issue by following methods:

Ensure dependencies described correctly on package.json Just run

npm install

Check issue still exists. and If issue not resolved, continue these methods.

npm cache clean

sudo npm install -g npm

npm cache clean

npm install

Comments

0

I found solution to this error. This error mostly occurs because you are not working on the right folder, cd to the right folder where you installed the npm or you can open the folder with vs code. For example, you have a main folder that contains the site or app folder, you need to be working from the subfolder and not the main folder, this is where you installed the npm and the dependencies are described correctly on package.json.

Comments

0

Your project workshop-vs-code-can-do-that does not have a packeage.json file available, to create it, go to terminal (on your project path), run this command npm init -y

Comments

0

Encountered the same error.

enter image description here

Root Cause:

  • Not installing(npm i) and starting(npm start) from the correct path in terminal

Solution:

  • Change the directory to the application directory where package.json present

enter image description here

hope this might help, Thanks.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.