Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Error: Cannot find module 'iltorb' #55

Closed
mtford90 opened this issue Aug 9, 2019 · 5 comments
Closed

[BUG] Error: Cannot find module 'iltorb' #55

mtford90 opened this issue Aug 9, 2019 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@mtford90
Copy link

mtford90 commented Aug 9, 2019

Environment

  • chrome-aws-lambda Version: 1.19.0
  • puppeteer / puppeteer-core Version: 1.19.0
  • OS: Amazon Linux
  • Node.js Version: 10.15
  • Lambda / GCF Runtime: nodejs10.x

Expected Behavior

iltorb should not be missing since it seems to be bundled with the package.

Current Behavior

Error during lambda invocation:

2019-08-09T17:15:36.459Z	34e925fd-e216-5eec-ab6e-703a4e79169f	ERROR	Invoke Error
{
    "errorType": "Error",
    "errorMessage": "Cannot find module 'iltorb'",
    "code": "MODULE_NOT_FOUND",
    "stack": [
        "Error: Cannot find module 'iltorb'",
        "    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)",
        "    at Module._require.o.require (/var/task/serverless_sdk/index.js:9:89041)",
        "    at require (internal/modules/cjs/helpers.js:25:18)",
        "    at inflate (/var/task/node_modules/chrome-aws-lambda/source/index.js:200:14)",
        "    at Function.get executablePath [as executablePath] (/var/task/node_modules/chrome-aws-lambda/source/index.js:159:7)",
        "    at constructMaterialDef (/var/task/src/webpack:/src/trending/generateTrendingMaterialFromMessage.ts:17:29)",
        "    at o.asyncWithScope (/var/task/src/webpack:/src/trending/generateTrendingMaterialFromMessage.ts:32:24)",
        "    at default (/var/task/src/webpack:/genolingo-raven-errors/lib/index.js:82:29)",
        "    at Hub.configureScope (/var/task/node_modules/@sentry/hub/dist/hub.js:278:13)",
        "    at callOnHub (/var/task/node_modules/@sentry/minimal/dist/index.js:17:28)",
        "    at Object.configureScope (/var/task/node_modules/@sentry/minimal/dist/index.js:77:5)",
        "    at a.default.sentryDSN.Promise (/var/task/src/webpack:/genolingo-raven-errors/lib/index.js:81:44)",
        "    at new Promise (<anonymous>)",
        "    at Object.this (/var/task/src/webpack:/genolingo-raven-errors/lib/index.js:81:22)",
        "    at Generator.next (<anonymous>)",
        "    at /var/task/src/webpack:/genolingo-raven-errors/lib/index.js:5:71"
    ]
}

Possible Solution

I noticed this line in the codebase:

 if (iltorb == null) {
    iltorb = require(process.env.AWS_EXECUTION_ENV !== 'AWS_Lambda_nodejs8.10' ? 'iltorb' : `${__dirname}/iltorb`);
  }

Given that i'm running nodejs10.15 I would assume this would have resolved to ${__dirname}/iltorb rather "iltorb" as it seems to have done from the error message.

Edit: read this wrong - it requires iltorb if NOT on 8.10. So am I supposed to be bundling and installing iltorb myself, then?

@mtford90 mtford90 added the bug Something isn't working label Aug 9, 2019
@mtford90
Copy link
Author

mtford90 commented Aug 9, 2019

I patched in iltorb using a layer and now i'm facing the following error:

2019-08-09T17:39:54.620Z	a93274ca-ddc6-54da-b100-210d6fe652f5	ERROR	Error getting browser instance Error: Failed to launch chrome!
/tmp/chromium: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory

This seems similar to #37 and so I guess I'll follow that thread for this new problem.

Do let me know if there's an easier way to fix this iltorb issue or if perhaps I missed something when setting this up.

@alixaxel
Copy link
Owner

alixaxel commented Aug 9, 2019

@mtford90 The issue is not (only) iltorb: that would be easy to fix.

The problem is actually the incompatibility with nodejs10.x, as stated in the README:

Due to unmet dependencies, the nodejs10.x AWS Lambda runtime is currently not supported.

You're right that this is related to #37, and I've actually uploaded those dependencies that you need here, but unfortunately it doesn't end there - you'd also need to bundle Fontconfig and at least one font.

Given that this setup is much more complex on 10.x it's probably best to just stick with 8.10 for now.

Closing this as a duplicate of #37.

@alixaxel alixaxel closed this as completed Aug 9, 2019
@simsketch
Copy link

Looks like the new nodejs runtimes are supported now.
This package works with the nodejs8.10, nodejs10.x and nodejs12.x AWS Lambda runtimes out of the box

I was able to get past the error with npm i iltorb

@simsketch
Copy link

next error was Failed to launch Chrome! which I was able to fix (locally) using

const browser = await chromium.puppeteer.launch({
     executablePath: undefined
})

@simsketch
Copy link

For code that works locally and in production, you can try this

            const browser = await chromium.puppeteer.launch({
                executablePath: process.env.NODE_ENV !== 'production'
                ? undefined
                : await chromium.executablePath,
            })

source: https://github.com/alixaxel/chrome-aws-lambda/issues/82#issuecomment-565575479

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants