1
votes

Every time I run node server.js this shows up. I've already tried installing and reinstalling new things but that doesn't work.

Error: Cannot find module '/Users/user/projects/node-express-server/server.json'

at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:191:16)
at bootstrap_node.js:612:3
Users-MBP-3:node101-express-server user$

2
What's the difference between the working directory you're launching node from, node101-express-server, and the directory node-express-server? - Jim B.

2 Answers

0
votes
Error: Cannot find module '/Users/user/projects/node-express-server/server.json'

should be server.js not server.json

0
votes

To run node app, you have to call it's server file not json file.

In your case , you have server.js file and you tried to call server.json file.

To prevent this type of mistake, install sudo npm install nodemon -g

Then just simple run nodemon, It will automatically use app/server file.