Bryant Caruthers
Bryant Caruthers

Reputation: 35

NPM Error code when trying to run npm start

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?

Upvotes: 2

Views: 12950

Answers (5)

Vishal
Vishal

Reputation: 1414

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.

Upvotes: 0

Sidrah Madiha Siddiqui
Sidrah Madiha Siddiqui

Reputation: 1374

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

Upvotes: 0

Dave-Web
Dave-Web

Reputation: 1

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.

Upvotes: 0

Prashanth Damam
Prashanth Damam

Reputation: 931

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

Upvotes: 1

Andrew Eisenberg
Andrew Eisenberg

Reputation: 28757

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?

Upvotes: 2

Related Questions