我正在AWS Lambda上运行一个视频处理脚本。
虽然它在本地(使用兰博达-本地进行了测试)似乎完全正常工作,但当它在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)"
]
}我正在上传的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(所需的马车位于processing.js中)
如果我打开ZIP,node_modules/fluent-ffmpeg/*确实存在。
我尝试使用以下方法将模块包括在内:
require("./node_modules/fluent-ffmpeg/index")require(__dirname + "./node_modules/fluent-ffmpeg/index")require(process.env.LAMBDA_TASK_ROOT + "/node_modules/fluent-ffmpeg/index")但这些都解决不了这个问题。我还尝试在我的机器rm -rf node_modules和npm install上重新安装节点和npm (以防万一)。
因为Lambda运行Node0.10.36,所以我也尝试在我的机器上使用这个版本来执行npm install,但是这也不会改变任何事情。
帮助感激。
谢谢!
发布于 2016-04-03 17:23:50
解决了。我的开发机器运行Windows 7,这显然是造成问题的原因.但会对原因感兴趣。
无论如何,在linux安装上运行npm install并将代码上传到Lambda就可以了。
https://stackoverflow.com/questions/36371794
复制相似问题