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.

Error: Cannot find module '@sparticuz/chromium

See original GitHub issue

I followed the instruction to create layer and attach it to the lambda function however I am still getting following error.

Test Event Name
event

Response
{
  "errorType": "Runtime.ImportModuleError",
  "errorMessage": "Error: Cannot find module '@sparticuz/chromium'\nRequire stack:\n- /var/task/index.js\n- /var/runtime/index.mjs",
  "trace": [
    "Runtime.ImportModuleError: Error: Cannot find module '@sparticuz/chromium'",
    "Require stack:",
    "- /var/task/index.js",
    "- /var/runtime/index.mjs",
    "    at _loadUserApp (file:///var/runtime/index.mjs:951:17)",
    "    at async Object.UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:976:21)",
    "    at async start (file:///var/runtime/index.mjs:1137:23)",
    "    at async file:///var/runtime/index.mjs:1143:1"
  ]
}

Function Logs
Unknown application error occurred
Runtime.ImportModuleError
2022-10-08T07:11:45.439Z	undefined	ERROR	Uncaught Exception 	{"errorType":"Runtime.ImportModuleError","errorMessage":"Error: Cannot find module '@sparticuz/chromium'\nRequire stack:\n- /var/task/index.js\n- /var/runtime/index.mjs","stack":["Runtime.ImportModuleError: Error: Cannot find module '@sparticuz/chromium'","Require stack:","- /var/task/index.js","- /var/runtime/index.mjs","    at _loadUserApp (file:///var/runtime/index.mjs:951:17)","    at async Object.UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:976:21)","    at async start (file:///var/runtime/index.mjs:1137:23)","    at async file:///var/runtime/index.mjs:1143:1"]}
2022-10-08T07:13:35.744Z	undefined	ERROR	Uncaught Exception 	{"errorType":"Runtime.ImportModuleError","errorMessage":"Error: Cannot find module '@sparticuz/chromium'\nRequire stack:\n- /var/task/index.js\n- /var/runtime/index.mjs","stack":["Runtime.ImportModuleError: Error: Cannot find module '@sparticuz/chromium'","Require stack:","- /var/task/index.js","- /var/runtime/index.mjs","    at _loadUserApp (file:///var/runtime/index.mjs:951:17)","    at async Object.UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:976:21)","    at async start (file:///var/runtime/index.mjs:1137:23)","    at async file:///var/runtime/index.mjs:1143:1"]}
START RequestId: 688c27ef-4936-4ebb-b55b-4f03edaad219 Version: $LATEST
END RequestId: 688c27ef-4936-4ebb-b55b-4f03edaad219
REPORT RequestId: 688c27ef-4936-4ebb-b55b-4f03edaad219	Duration: 1426.51 ms	Billed Duration: 1427 ms	Memory Size: 128 MB	Max Memory Used: 12 MB	
Unknown application error occurred
Runtime.ImportModuleError

Request ID
688c27ef-4936-4ebb-b55b-4f03edaad219
Screenshot 2022-10-08 at 12 55 02 PM

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
Gonzalo8642commented, Nov 3, 2022

I followed the new section which linked to the CI runs. The artefact I download from Sparticuz/chromium/actions/runs/3191558127 is the one that includes an extra chromium.zip

Ah, ok. It looks like github is adding an extra zip layer. I wonder if they just zip up all artifacts. The correct file to use as the lambda layer is the chromium.zip INSIDE of the github artifact. I will make a note about this.

Also, yes, changing to a regular production dependency will work just fine because then you are packaging the binaries directly with your code, but many of us run into deployment limits because it’s over 50 megs.

I’m on a mac and it unzipped both of them, which is why it took me a while to stumble into this issue. For a split second I can see both of them expanding image

If I go to the terminal and use unzip chromium.zip -d temp it will only unzip the first one.

0reactions
Sparticuzcommented, Nov 28, 2022

I’m going to close this issue as it’s easily solved by following these instructions.

https://github.com/Sparticuz/chromium#aws-lambda-layer

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I resolve "Cannot find module" error using Node.js?
Using npm install installs the module into the current directory only (in a subdirectory called node_modules ). Is app.js located under ...
Read more >
cannot find module [Node npm Error Solved] - freeCodeCamp
In my case, I got it like this "Module not found: Error: Can't resolve 'react-icons/fa' in 'C:\Users\user\Desktop\Projects\Address Locator\ ...
Read more >
Error: Cannot find module 'bcrypto.node' · Issue #127 - GitHub
i got some error here D:\DataGalang\test-cepot\hs-airdrop\node_modules\loady\lib\loady.js:156 throw err; ^ Error: Cannot find module ...
Read more >
@sparticuz/chrome-aws-lambda - npm
Chromium Binary for AWS Lambda and Google Cloud Functions, forked from @alixaxel/chrome-aws-lambda. Latest version: 17.1.3, last published: ...
Read more >
[Solution] Error: Cannot Find Module "nodemailer" - Courier
This is a common Nodemailer error -- get the solution for Error: Cannot Find Module "nodemailer".
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