loading...

How to Solve a AWS Lambda error - Runtime.ImportModuleError: Error: Cannot find module 'jmespath'

konyu profile image @kon_yu Updated on ・1 min read

AWS Lambda scripts written in nodejs8 were deprecated.
You run the same scripts via AWS Lambda nodejs10 or nodejs12 environment and may hit the following error message.

{"errorType":"Runtime.ImportModuleError","errorMessage":"Error: Cannot find module 'jmespath'","stack":["Runtime.ImportModuleError: Error: Cannot find module 'jmespath'","    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:36:30)","    at Module._compile (internal/modules/cjs/loader.js:701:30)","    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)","    at Module.load (internal/modules/cjs/loader.js:600:32)","    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)","    at Function.Module._load (internal/modules/cjs/loader.js:531:3)","    at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)","    at startup (internal/bootstrap/node.js:283:19)"]}

I hit the same problem Error: Cannot find module 'jmespath' and solved it.

Do you use aws-sdk via node_modules? like follows

var aws = require('aws-sdk');

If so you just remove aws-sdk from node_modules.

to remove aws-sdk for yarn

yarn remove aws-sdk

remove aws-sdk for npm

npm uninstall aws-sdk

aws-sdk has been included to lambda since nodejs10. see: https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html

I hit the same problem Error: Cannot find module 'jmespath' and solved it.

Do you use aws-sdk via node_modules? like follows

var aws = require('aws-sdk')

If so you just remove aws-sdk from node_modules.

remove aws-sdk for yarn

yarn remove aws-sdk

remove aws-sdk for npm

npm uninstall aws-sdk

aws-sdk has been…

Discussion

pic
Editor guide