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

Cannot find module... Error when looking up module saml2-js in node_modules directory #95

Open
pascencio opened this issue Mar 4, 2020 · 1 comment

Comments

@pascencio
Copy link

pascencio commented Mar 4, 2020

Hi people!

I'm trying to deploy a lambda function to use it in CloudFront. The problem with the lambda function is the size of the package is over the 1mb, that is not supported in lambda@edge.

I decided to use serverless-plugin-optimize to minify my lambda package, but there is some trouble with modules that are importe using the node_modules directory. For example, the module saml2-js use an index.js file that import the exported module from another javascript file. This behavior repeats with other modules in the same condition.

2020-03-04T02:27:14.705Z	undefined	ERROR	Uncaught Exception 	
{
    "errorType": "Runtime.ImportModuleError",
    "errorMessage": "Error: Cannot find module '/var/task/_optimize/<function>/node_modules/saml2-js/lib-js/saml2'\nRequire stack:\n- /var/task/_optimize/<function>/facade.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js",
    "stack": [
        "Runtime.ImportModuleError: Error: Cannot find module '/var/task/_optimize/<function>/node_modules/saml2-js/lib-js/saml2'",
        "Require stack:",
        "- /var/task/_optimize/<function>/facade.js",
        "- /var/runtime/UserFunction.js",
        "- /var/runtime/index.js",
        "    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:43:30)",
        "    at Module._compile (internal/modules/cjs/loader.js:955:30)",
        "    at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)",
        "    at Module.load (internal/modules/cjs/loader.js:811:32)",
        "    at Function.Module._load (internal/modules/cjs/loader.js:723:14)",
        "    at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)",
        "    at internal/main/run_main_module.js:17:11"
    ]
}

Are there any settings I can use?

Thanks in the advance!

@maazmk
Copy link

maazmk commented Jul 30, 2020

Any update on 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