简体   繁体   English

在AWS Lambda上'找不到模块fluent-ffmpeg'

[英]'Cannot find module fluent-ffmpeg' on AWS Lambda

I'm running a video processing script on AWS Lambda. 我正在AWS Lambda上运行视频处理脚本。

While it seems to work perfectly locally (tested using lambda-local ), I'm having a strange issue when it runs on Lambda: 尽管它似乎可以在本地完美运行(使用lambda-local测试),但是当它在Lambda上运行时却遇到了一个奇怪的问题:

{
  "errorMessage": "Cannot find module 'fluent-ffmpeg'",
  "errorType": "Error",
  "stackTrace": [
    "Function.Module._resolveFilename (module.js:338:15)",
    "Function.Module._load (module.js:280:25)",
    "Module.require (module.js:364:17)",
    "require (module.js:380:17)",
    "Object.<anonymous> (/var/task/processing.js:2:14)",
    "Module._compile (module.js:456:26)",
    "Object.Module._extensions..js (module.js:474:10)",
    "Module.load (module.js:356:32)",
    "Function.Module._load (module.js:312:12)",
    "Module.require (module.js:364:17)"
  ]
}

The ZIP I am uploading contains the following files: 我要上传的ZIP包含以下文件:

~$ find . -maxdepth 2
.
./bin
./bin/ffmpeg
./config.js
./event-samples
./event-samples/custom.js
./event-samples/dynamodb-update.js
./event-samples/kinesis.js
./event-samples/s3-put.js
./frames
./Gulpfile.js
./index.js
./node_modules
./node_modules/async
./node_modules/aws-sdk
./node_modules/fluent-ffmpeg
./node_modules/gulp
./node_modules/gulp-awslambda
./node_modules/gulp-zip
./package.json
./processing.js
./utils.js

(The buggy require is located in processing.js ) (越野车的需求位于processing.js中

If I open the ZIP, node_modules/fluent-ffmpeg/* does exist. 如果我打开ZIP, node_modules/fluent-ffmpeg/*确实存在。

I tried to include the module using: 我尝试使用以下方式包含该模块:

  • require("./node_modules/fluent-ffmpeg/index")
  • require(__dirname + "./node_modules/fluent-ffmpeg/index")
  • require(process.env.LAMBDA_TASK_ROOT + "/node_modules/fluent-ffmpeg/index")

But none of these solved the problem. 但是这些都不能解决问题。 I also tried reinstalling node and npm on my machine, rm -rf node_modules and npm install (just in case). 我还尝试在计算机上重新安装node和npm, rm -rf node_modulesnpm install (以防万一)。

Since Lambda runs Node 0.10.36, I also tried using this version on my machine to do the npm install , but that doesn't change anything either. 由于Lambda运行Node 0.10.36,因此我也尝试在计算机上使用此版本进行npm install ,但这也没有任何改变。

Help appreciated. 帮助表示赞赏。

Thanks! 谢谢!

Solved. 解决了。 My development machine runs Windows 7, and that's apparently what caused the issue... Would be interested in the reasons, though. 我的开发计算机运行Windows 7,这显然是导致问题的原因……不过,对这些原因很感兴趣。

Anyway, running npm install on a linux installation and uploading the code to Lambda did the trick. 无论如何,在Linux npm install上运行npm install并将代码上传到Lambda可以解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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