DEV Community

@kon_yu
@kon_yu

Posted on • Edited on

3 4

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

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)"]}


Enter fullscreen mode Exit fullscreen mode

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');


Enter fullscreen mode Exit fullscreen mode

If so you just remove aws-sdk from node_modules.

to remove aws-sdk for yarn



yarn remove aws-sdk


Enter fullscreen mode Exit fullscreen mode

remove aws-sdk for npm



npm uninstall aws-sdk


Enter fullscreen mode Exit fullscreen mode

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…

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more