question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ImportModuleError

See original GitHub issue

I have a rather simple serverless config, with no other plugins, no package exclude patters, yet I get a ModuleImportError upon deployment. The only potential deviation from the most basic example in the README is that I’ve configured Serverless to build and deploy an image rather than a zip. Any ideas?

{
  "errorType": "Runtime.ImportModuleError",
  "errorMessage": "Error: Cannot find module 's_warmUpPluginWarmer'\nRequire stack:\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js",
  "trace": [
    "Runtime.ImportModuleError: Error: Cannot find module 's_warmUpPluginWarmer'",
    "Require stack:",
    "- /var/runtime/UserFunction.js",
    "- /var/runtime/index.js",
    "    at _loadUserApp (/var/runtime/UserFunction.js:202:13)",
    "    at Object.module.exports.load (/var/runtime/UserFunction.js:242:17)",
    "    at Object.<anonymous> (/var/runtime/index.js:43:30)",
    "    at Module._compile (internal/modules/cjs/loader.js:1085:14)",
    "    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)",
    "    at Module.load (internal/modules/cjs/loader.js:950:32)",
    "    at Function.Module._load (internal/modules/cjs/loader.js:790:12)",
    "    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)",
    "    at internal/main/run_main_module.js:17:47"
  ]
}

My Serverless config:

provider:
  name: aws
  region: eu-west-1
  memorySize: 1024
  timeout: 900 #sec
  deploymentBucket:
    name: ${opt:stage}-smp-serverless-deployment
  iam:
    role: ${ssm:/${opt:stage}-lambda-serverless-role-arn}
  ecr:
    images:
      appimage:
        path: ./

plugins:
  - serverless-plugin-warmup

functions:
  main:
    name: ${opt:stage}-conv
    environment:
      INPUT_S3_BUCKET: ${ssm:/${opt:stage}-file-upload-bucket-name}
    image:
      name: appimage

custom:
  warmup:
    warmer:
      enabled: true
    package:
      events:
        - schedule: rate(10 minutes)
      concurrency: 10`

Many thanks in advance!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:29 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
brendenkrochkocommented, Jul 4, 2022

@juanjoDiaz Thanks for the prompt response. My mistake on the version number, that was a mistype on my end! 7.1.0 is the one I am on.

So I actually just got everything working on my end using what minu2020 had pasted above (adding in the package options to my config) on Feb 1, 2022. I’m still not entirely sure what the issue was, but everything seems to be alright now.

The warmup config that I am now using successfully is:

warmup:
  default:
    prewarm: true
    package:
      individually: true
      patterns:
        - "!../**"
        - "!../../**"
        - ./serverless_sdk/*
        - ./s_warmUpPluginDefault.js
0reactions
alanwiltercommented, Nov 2, 2022

Well, I was very sceptical it would work with docker package but hooray, it did!:

  warmup:
    default:
      prewarm: true
      enabled: true
      events:
        - schedule: cron(0/5 1-23 ? * MON-SUN *)
      concurrency: 5
      verbose: true
      logRetentionInDays: 14
      package:
        individually: true
        patterns:
          - "!../**"
          - "!../../**"
          - ./serverless_sdk/*
          - ./s_warmUpPluginDefault.js
Read more comments on GitHub >

github_iconTop Results From Across the Web

"Runtime.ImportModuleError" trying to access npm ...
ImportModuleError : Error: Cannot find module 'request'", "Require stack:", ... ...as if the layer had never been added. The error is exactly the ......
Read more >
Resolve the "Unable to import module" error for Lambda code ...
I receive the "Unable to import module" error when I try to run my AWS Lambda code in Node.js. Short description. You typically...
Read more >
Lambda fails: "Runtime.ImportModuleError: Error: Cannot find ...
After successfully deploying my stack using serverless deploy , my lambda functions fail, citing a module import error Runtime.ImportModuleError ...
Read more >
Prisma cloud[ERROR] Runtime.ImportModuleError: Unable to ...
We are getting the following error in our Lambdas, [ERROR] Runtime.ImportModuleError: Unable to import module 'twistlock': Failed to import - 404799.
Read more >
How to Solve a AWS Lambda error - Runtime.ImportModuleError
ImportModuleError : Error: Cannot find module 'jmespath'. AWS Lambda scripts written in nodejs8 were deprecated. You run the same scripts via AWS ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found