Deployed Nodejs REST API on AWS using Elastic Beanstitch - Error cannot find custom module
I wrote my first nodejs app. It works fine on my macbook, but when I try to deploy it on AWS elastic beanstalk, I get below error.
/var/log/nodejs/nodejs.log
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
module.js:338
throw err;
^
Error: Cannot find module '**./routes/userprofile**'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/var/app/current/main.js:7:18)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
Nodejs seems to be able to resolve the path for my custom userprofile module which is in the Routes directory. I tried to move userprofile.js to the root directory but it still can't resolve it.
This is the code in main.js that loads all modules
/ Download our modules
var express = require('express');
var bodyParser = require('body-parser');
var userprofile = require('./routes/userprofile');
Problem: It looks like this line requires ('./routes/userprofile')
Does anyone have an idea what I might be doing wrong? Would be grateful for any help.
Thank.
+3
source to share
No one has answered this question yet
Check out similar questions: