admin管理员组

文章数量:1323200

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 plete 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?

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 plete 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?

Share Improve this question edited Jan 21, 2024 at 14:00 Iriza Peace 34 bronze badges asked Nov 6, 2019 at 3:42 Bryant CaruthersBryant Caruthers 351 gold badge1 silver badge7 bronze badges 1
  • Try running the npm install and then start the project by npm start – Prashanth Damam Commented Nov 6, 2019 at 4:41
Add a ment  | 

5 Answers 5

Reset to default 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?

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

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.

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 mand npm init -y

Encountered the same error.

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

hope this might help, Thanks.

本文标签: javascriptNPM Error code when trying to run npm startStack Overflow