node.jsnpm

npm ERR! enoent ENOENT: no such file or directory, open package.json


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
└─┬ ws@1.1.1 
  ├── options@0.0.6 
  └── ultron@1.0.2 

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.


Solution

  • 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.