简体   繁体   中英

“Cannot find module” error message when deploying a node.js program on Heroku or RedHat Openshift Online

`Environment: 
    DEV_MODE=false
    NODE_ENV=production
    DEBUG_PORT=5858
Launching via npm...
npm info it worked if it ends with ok
npm info using npm@5.6.0
npm info using node@v8.9.4
npm info lifecycle SuperCineBot@1.0.0~prestart: SuperCineBot@1.0.0
npm info lifecycle SuperCineBot@1.0.0~start: SuperCineBot@1.0.0

SuperCineBot@1.0.0 start /opt/app-root/src
node main

module.js:540
    throw err;
    ^

Error: Cannot find module './dnssec'
    at Function.Module._resolveFilename (module.js:538:15)
    at Function.Module._load (module.js:468:25)
    at Module.require (module.js:587:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/opt/app-root/src/node_modules/sshpk/lib/formats/auto.js:16:14)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)
npm info lifecycle SuperCineBot@1.0.0~start: Failed to exec start script
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! SuperCineBot@1.0.0 start: `node main`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the SuperCineBot@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /opt/app-root/src/.npm/_logs/2018-05-07T20_59_43_900Z-debug.log
`

Hello,

I know that the question as been posted many times already but I'm having trouble deploying my code ( https://github.com/yukinoe/kizabot ) either on Heroku or Redhat Openshift Online. I have the same error message even if "./dnssec" module is in the node_modules folder.

Anyone has an idea ?

Thanks for the help.

You're importing via a relative path, so you need to make sure that dnssec.js exists next to whomever is doing the importing (perhaps index.js in your case).

So your hierarchy needs to look a bit like this:

./src
   index.js
   dnssec.js

node_modules doesn't fit into this one, since imports from there shouldn't be relative.

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