0

I'm new to Node so bear with me.

I have a Node server which requires ws so I install it with:

$ npm install ws
/private/var/www/html/WebRTC/SVC
└─┬ [email protected] 
  ├── [email protected] 
  └── [email protected] 

npm WARN enoent ENOENT: no such file or directory, open '/private/var/www/html/WebRTC/SVC/package.json'
npm WARN SVC No description
npm WARN SVC No repository field.
npm WARN SVC No README data
npm WARN SVC No license field.

I then run the server using:

$ npm run server.js 
npm ERR! Darwin 15.6.0
npm ERR! argv "/usr/local/Cellar/node/6.2.2/bin/node" "/usr/local/bin/npm" "run" "server.js"
npm ERR! node v6.2.2
npm ERR! npm  v3.9.5
npm ERR! path /private/var/www/html/WebRTC/SVC/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open

npm ERR! enoent ENOENT: no such file or directory, open '/private/var/www/html/WebRTC/SVC/package.json'
npm ERR! enoent ENOENT: no such file or directory, open '/private/var/www/html/WebRTC/SVC/package.json'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! Please include the following file with any support request:
npm ERR!     /private/var/www/html/WebRTC/SVC/npm-debug.log

but am getting errors mentioning no package.json.

Looking through npm-debug.log it seems pretty much the same.

Can someone shed some light on what enoent is and what sort of package.json file I need.

I was expecting this script to run out of the box so a little puzzled.

3
  • 3
    Did you run npm init when you started the project?
    – Aurora0001
    Commented Oct 16, 2016 at 17:13
  • 1
    Try node server.js instead of npm run server.js. Commented Oct 16, 2016 at 18:39
  • @Aurora0001 I know it's old, but "npm init" did the trick for me. I'm using Visual Studio Code Insiders and created dotnet core mvc project. Commented Mar 19, 2018 at 14:47

7 Answers 7

1

When you type

npm run server.js

npm tries to find entry named server.js in the scripts section of your package.json file (see npm docs on scripts for details).

package.json, simplified, describes your app's dependencies and environment.

As you don't have such file, npm fails with ENOENT, which is an abbreviation for Error NO ENTry. Basically, in your case, you just want to node server.js to run your script.

0

This command works for me:

npm install -g expo-cli --force
0

Following commands worked for me:

npm cache clean --force
node server.js
0

Try following steps

  1. Reinstall npm: open cmd as an administrator and run npm uninstall -g npm
  2. Go to your directory and open cmd
  3. Clear npm Cache using npm cache clean -f
  4. Now you can update npm using npm install -g npm@latest
0

Try this in cmd, it will work for sure! Navigate to this file.

cd C:\Users\hp\AppData\Roaming

then enter

mkdir npm
0

I had same issue solved like this:

Just run this command: npm config set legacy-peer-deps true

& then

npm install

0
npm error code ENOENT
npm error syscall lstat
npm error path C:\Users\yourUsername\AppData\Roaming\npm
npm error errno -4058
npm error enoent ENOENT: no such file or directory, lstat 'C:\Users\yourUsername\AppData\Roaming\npm'
npm error enoent This is related to npm not being able to find a file.
npm error enoent

npm error A complete log of this run can be found in: C:\Users\yourUsername\AppData\Local\npm-cache\_logs\2024-07-09T10_24_04_497Z-debug-0.log

To Resolve the above error in vs code:

Firstly, check whether the folder having all the permissions or not if not

Right click on the folder > Properties > security > Allow all permissions and make sure to uncheck the read-only option in general.

1
  • The lack of proper code formatting makes it difficult for readers to help you. Please edit your question to format inline code properly and to use a code block for any code or error messages you have included.
    – Adam Basha
    Commented Jul 9 at 13:52

Not the answer you're looking for? Browse other questions tagged or ask your own question.