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 using moduleDirectories in AWS Lambda #132

Open
allenada opened this issue Nov 12, 2022 · 1 comment
Open

Bug using moduleDirectories in AWS Lambda #132

allenada opened this issue Nov 12, 2022 · 1 comment

Comments

@allenada
Copy link

I'm unable to use moduleDirectories specification when deploying code to AWS Lambda

I believe bug is in this function

function getMainModule () {
  return require.main._simulateRepl ? undefined : require.main
}

Error I get is:

2022-11-12T00:51:00.555Z	undefined	ERROR	Uncaught Exception 	
{
    "errorType": "TypeError",
    "errorMessage": "Cannot read properties of undefined (reading '_simulateRepl')",
    "stack": [
        "TypeError: Cannot read properties of undefined (reading '_simulateRepl')",
        "    at getMainModule (/var/task/node_modules/module-alias/index.js:216:23)",
        "    at addPath (/var/task/node_modules/module-alias/index.js:85:22)",
        "    at /var/task/node_modules/module-alias/index.js:210:7",
        "    at Array.forEach (<anonymous>)",
        "    at init (/var/task/node_modules/module-alias/index.js:206:35)",
        "    at Object.<anonymous> (/var/task/node_modules/module-alias/register.js:1:13)",
        "    at Module._compile (node:internal/modules/cjs/loader:1105:14)",
        "    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)",
        "    at Module.load (node:internal/modules/cjs/loader:981:32)",
        "    at Function.Module._load (node:internal/modules/cjs/loader:822:12)"
    ]
}

Seems fix should be to rewrite the method as:

function getMainModule () {
  return require.main && require.main._simulateRepl ? undefined : require.main
}
@allenada allenada changed the title Bug using moduleDirectories when Bug using moduleDirectories in AWS Lambda Nov 12, 2022
@Kehrlann
Copy link
Collaborator

Hey @allenada 👋

Isn't moduleDirectories a Jest thing?

In any case, would you care to open a pull request for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants