examples icon indicating copy to clipboard operation
examples copied to clipboard

cannot find module Error despite depedencies being installed

Open thomasfaller opened this issue 3 years ago • 0 comments

Hey folks,

Following the serverless docs for the aws-node-twilio example, I get the following message even though I installed all dependencies (tried via npm and yarn as well). I removed the node_modules directory and ran a full npm install as well and that doesn't change anything.

Weird thing is that a local invoke will work but not a 'normal' invoke eve though I did a sls deploy to make sure all the deps are deployed.

I tried with the latest twilio package but I also get an error.

Any thoughts ?

{
    "errorType": "Runtime.ImportModuleError",
    "errorMessage": "Error: Cannot find module 'underscore'\nRequire stack:\n- /var/task/node_modules/twilio/lib/webhooks.js\n- /var/task/node_modules/twilio/lib/index.js\n- /var/task/handler.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js",
    "trace": [
        "Runtime.ImportModuleError: Error: Cannot find module 'underscore'",
        "Require stack:",
        "- /var/task/node_modules/twilio/lib/webhooks.js",
        "- /var/task/node_modules/twilio/lib/index.js",
        "- /var/task/handler.js",
        "- /var/runtime/UserFunction.js",
        "- /var/runtime/index.js",
        "    at _loadUserApp (/var/runtime/UserFunction.js:100:13)",
        "    at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)",
        "    at Object.<anonymous> (/var/runtime/index.js:43:30)",
        "    at Module._compile (internal/modules/cjs/loader.js:1015:30)",
        "    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)",
        "    at Module.load (internal/modules/cjs/loader.js:879:32)",
        "    at Function.Module._load (internal/modules/cjs/loader.js:724:14)",
        "    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)",
        "    at internal/main/run_main_module.js:17:47"
    ]
}
 
  Error --------------------------------------------------
 
  Error: Invoked function failed
      at AwsInvoke.log (/snapshot/serverless/lib/plugins/aws/invoke/index.js:100:31)
  From previous event:
      at Object.invoke:invoke [as hook] (/snapshot/serverless/lib/plugins/aws/invoke/index.js:23:12)
      at /snapshot/serverless/lib/classes/PluginManager.js:521:55
  From previous event:
      at PluginManager.invoke (/snapshot/serverless/lib/classes/PluginManager.js:521:22)
      at /snapshot/serverless/lib/classes/PluginManager.js:556:24
  From previous event:
      at PluginManager.run (/snapshot/serverless/lib/classes/PluginManager.js:556:8)
      at /snapshot/serverless/lib/Serverless.js:203:33
      at processImmediate (internal/timers.js:456:21)
      at process.topLevelDomainCallback (domain.js:137:15)
  From previous event:
      at Serverless.run (/snapshot/serverless/lib/Serverless.js:190:74)
      at /snapshot/serverless/scripts/serverless.js:50:26
 
  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com
 
  Your Environment Information ---------------------------
     Operating System:          linux
     Node Version:              12.18.1
     Framework Version:         2.15.0 (standalone)
     Plugin Version:            4.2.0
     SDK Version:               2.3.2
     Components Version:        3.4.3

thomasfaller avatar Dec 16 '20 13:12 thomasfaller