-2

I'd like to run node.js server on my machine but I get this error. What should I do? (Please note I'm not programmer :)

MBP-Mike:~ michal$ node server
internal/modules/cjs/loader.js:638
    throw err;
    ^

Error: Cannot find module '/Users/michal/server'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Function.Module.runMain (internal/modules/cjs/loader.js:829:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
  • 3
    seems like there's no file named 'server' in directory '/Users/michal/' – moghya Jul 21 '19 at 17:16
  • @MikeAcler There's really nothing we can do to help you in this case. We don't know what specifically you're trying to do. We don't know what you did to attempt to install whatever it is you're trying to run. – Brad Jul 21 '19 at 17:21
  • Maybe you could show what is happening in `loader.js`, line 638? – The Witness Jul 21 '19 at 18:39

2 Answers2

-1

to run a nodejs server: node example: if your server file is called server.js

node /Users/Michal/server.js
  • Node will implicitly load `server.js` even if you were to type `node server`, as he did. – Brad Jul 21 '19 at 17:23
-1

it seems like you missed the .js extension on your command.

node server.js 

Or you can just run

node .
  • Node will implicitly load server.js even if you were to type node server, as he did. You won't be able to run `node .` unless package.json is configured this way, or you're using `index.js`. – Brad Jul 21 '19 at 17:34