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…

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay