简体   繁体   中英

'Cannot find module fluent-ffmpeg' on AWS Lambda

I'm running a video processing script on AWS Lambda.

While it seems to work perfectly locally (tested using lambda-local ), I'm having a strange issue when it runs on 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:

~$ 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 )

If I open the ZIP, node_modules/fluent-ffmpeg/* does exist.

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).

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.

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.

Anyway, running npm install on a linux installation and uploading the code to Lambda did the trick.

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