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
rest node.js amazon-web-services elastic-beanstalk


source to share


No one has answered this question yet

Check out similar questions:

125
ReferenceError: describe undefined NodeJs
eleven
return process.dlopen (module, path._makeLong (filename));
3
AWS Node.js Deployment Error: Cannot Find Module
3
appium failed to start - tools with uncaught errors
2
export function problems with babel and nodejs
1
VS 2015 Gulp Failed to load message
1
qr-js npm package not installed
1
Error connecting oracle database with node
1
Error: Cannot find module "less"
0
Error: Cannot find module 'res' in server.js



All Articles
Loading...
X
Show
Funny
Dev
Pics