简体   繁体   中英

ElasticBeanstalk nodejs.log can't find module 'hogan.js'

I have a simple node.js app that is using "hogan": "^1.0.2" (from packages.json under "dependencies" ).

It has been failing to deploy, and looking in the logs, I am seeing (multiple times):

Error: Cannot find module 'hogan.js' at Function.Module._resolveFilename (module.js:325:15) at Function.Module._load (module.js:276:25) at Module.require (module.js:353:17) at require (internal/module.js:12:17)

I'm fairly new to node.js on EB, and have just been following http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_nodejs_express.html with a pre-existing Express app.

Assuming EB runs npm install for me (is that a safe assumption?), what might the issue be?

For what it's worth, I also had an issue similar to this and determined that it was due to file case issues. In the node EB container, the OS is case-sensitive, and because I was ignoring file case changes in git, it didn't update the file casing in the repository.

You should run git config core.ignorecase false if this is the issue.

I was using "hogan": "^1.0.2" instead of "hogan.js": "^3.0.2" , which worked locally but not on EB.

hogan is just an unofficial alias someone made to hogan.js .

I do not get hogan.js errors any more after making the switch.

You might also change "hogan": "^3.0.2" to "hogan": "*" because EB does run npm install for you. If EB can't find the specific version with "^", it might not install the package as you did locally. Also you might check your file structure before you do eb create or eb deploy . You might include something unnecessary if you are using the command line. I suggest that you create an application.zip file with files you need, such as package.json , app.js and index.html and upload it through GUI. Don't ever pack up node_modules in your .zip file, that's troublesome.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM