Vikas Biradargoudar
Vikas Biradargoudar

Reputation: 134

Node server error

I'm using Ubuntu 16.04 LTS operating system.

When I run node -v, it is showing v4.2.6.

When I run npm -v, it is showing 3.5.2.

But when I am trying to run the node server using the command node server, it is throwing an error(s). The error is shown below:

module.js:328
    throw err;
    ^

Error: Cannot find module '/opt/lampp/htdocs/angularjs/server'
    at Function.Module._resolveFilename (module.js:326:15)
    at Function.Module._load (module.js:277:25)
    at Function.Module.runMain (module.js:442:10)
    at startup (node.js:136:18)
    at node.js:966:3

Any help is appreciated.

Upvotes: 0

Views: 1906

Answers (2)

Syed Ayesha Bebe
Syed Ayesha Bebe

Reputation: 1448

  1. Make sure the path from which you are running the server code.
  2. And check the spelling of your file name you are running and the file that exists in folder i.e., it may be typo error also.

I am sure this error occurs when you are running the code which is not in the path. Go to the path where the folder exists and run the code there.

If you see this image First my file index.js file doesn't exists in this path when I run index.js I got this error.

enter image description here

Now I navigate to a folder where my index.js file exists.When I run index.js I got the response

enter image description here

Hope this helps.

Upvotes: 1

danday74
danday74

Reputation: 56936

Instead of node server try node server.js see if that helps.

Make sure you server file has a .js extension as that is what node is looking for.

Upvotes: 0

Related Questions