'npm install error: 'ENOENT: no such file or directory'

I donwload a project form somewhere , and I run 'npm install' , I got this:

npm ERR! path /Users/<username>/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open '/Users/<username>/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

but I have checked the project , there were a package.json file there: /Users/username/Desktop/Directory/Projects/ProjectName/package.json

do I need to use npm init to create another one?



Solution 1:[1]

cd to the directory where package.json is (/Users/username/Desktop/Directory/Projects/ProjectName/ in your case) and run npm install again.

Solution 2:[2]

Simplest solution:

Simply run npm init and it will walk you through the process of creating package.json file

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 azr