Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

cannot find module Error despite depedencies being installed

未关闭
#574 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
aws, javascript, node.js
领域
backend, cloud

调研方向

从 aws-node-twilio 示例及其入口点 handler.js 开始,然后比较本地 invoke 期间可用的依赖项与已部署函数中的依赖项。使用 sls deploy 后执行一次普通 invoke 来复现问题,并追踪 twilio/lib/webhooks.js 无法加载 underscore 的原因。已部署的示例能够在 underscore 可用的情况下成功 invoke,即表示完成。

由索引模型根据 Issue 内容生成。

描述

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
主要语言
JavaScript
星标
11.5k
派生
4.4k
平均合并
2 小时 55 分钟
30 天内合并 PR
3

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

serverless/examples 的其他 Issue

查看 serverless/examples 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。