Foundation Certificate in Test Automation - npm install - ENOENT: no such file or directory

Hi team, I am working on the foundation Javascript test automation course, and after installing node.js and npm from the node website, I run ‘npm install’ in VS code as instructed but I get the following error, which seems to be preventing me from executing the install. Any help would be greatly appreciated, thanks!

npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /Users/Jayla/test-automation/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/Users/Jayla/test-automation/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: /Users/Jayla/.npm/_logs/2024-01-31T10_14_30_140Z-debug-0.log
4 Likes

Hmm well this seems to be what has resolved the issue, for anyone checking out this thread. Though I am not sure why it resolved it or what this even does lol

I ran:
npm init -y

then re-ran npm install and I see no error now

Jamess-MacBook-Pro:~ Jayla$ npm init -y
Wrote to /Users/Jayla/package.json:

{
  "name": "jayla",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}


Jamess-MacBook-Pro:~ Jayla$ npm install

up to date, audited 1 package in 533ms

found 0 vulnerabilities
3 Likes

Hi James,

The initial error you received was because you were running npm install in a folder that didn’t contain a package.json file which contains the dependencies. Running npm init creates a new package.json file, hence why you no longer saw the error.

4 Likes

Thank you Mark! Yeah I had read something along the same lines but the thing that threw me was I installed the node.js and npm to the main Mac drive so I assumed it would have the package there in my main folder… (if that makes sense? ) but at least it’s now resolved, happy to continue going through the course :raised_hands: :clap:

1 Like