Can't get it working in Lambda (Cannot find module 'vite-plugin-ssr/dist/cjs/node/index.js')
See original GitHub issueHey there ☺️
I’m trying to deploy a Vite React app using vite-plugin-ssr to provide SSR but testing the Lambda via AWS Console results in Cannot find module 'vite-plugin-ssr/dist/cjs/node/index.js'
so it seems it’s not correctly bundling the right version or something?
I opened an issue at the plugin repo but was told it’s more likely some bundling issue with Pulumi
I’m running
pulumi version => v3.10.3
node -v => v16.5.0
The full error from the AWS Lambda Console:
{
"errorType": "Error",
"errorMessage": "Cannot find module 'vite-plugin-ssr/dist/cjs/node/index.js'\nRequire stack:\n- /var/task/__index.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js",
"trace": [
"Error: Cannot find module 'vite-plugin-ssr/dist/cjs/node/index.js'",
"Require stack:",
"- /var/task/__index.js",
"- /var/runtime/UserFunction.js",
"- /var/runtime/index.js",
" at Function.Module._resolveFilename (internal/modules/cjs/loader.js:889:15)",
" at Function.Module._load (internal/modules/cjs/loader.js:745:27)",
" at Module.require (internal/modules/cjs/loader.js:961:19)",
" at require (internal/modules/cjs/helpers.js:92:18)",
" at /var/task/__index.js:80:15",
" at Object.__f2 [as createPageRender] (/var/task/__index.js:85:6)",
" at /var/task/__index.js:105:32",
" at Generator.next (<anonymous>)",
" at /var/task/__index.js:16:71",
" at new Promise (<anonymous>)"
]
}
Steps to reproduce
git clone https://github.com/CanRau/pulumi-bundle-issue
yarn
cd www
yarn && yarn build
cd ..
pulumi up
to some test environment if possible
Expected: Working Lambda Actual: Error as in title
I use www/server/lambda.ts
as Lambda function handler index.ts#L3
Which as mentioned in the plugins docs imports import "../dist/server/importBuild";
Actually lambda.ts
itself already imports vite-plugin-ssr
.
Maybe I’ve got some tsconfig.json
confusions?
Let me know if I can provide anything else 🙏
Issue Analytics
- State:
- Created 2 years ago
- Comments:6
Wow, thanks that’s really interesting, I just cloned my own repo, into a new dir, following above steps,
pulumi up
ed it and voila it completely worked, not even thetoLowerCase
issue 😳😅 Not yet sure what the difference between the cloned and the original repos is though 🧐Thank you anyway for taking the time 🙏 I’ll post here if I’ll find out the difference and remember to do so 🤞
Yeah because it’s supposed to be a APIGateway event and I don’t yet verify it and just access
toLowerCase
onevent.httpMethod
😅 And maybe because of this you don’t get the “correct” error as it fails earlier