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.

Can't get it working with Pulumi

See original GitHub issue

So I’m trying to deploy to AWS Lambda using Pulumi, I’m not sure, it might be a Pulumi bundling issue, though before I hadn’t issues with that.

I’ve got a separate ./server/lambda.ts which includes import "../dist/server/importBuild"; And as importBuild includes const { __private: { importBuild } } = require("vite-plugin-ssr") it should import vite-plugin-ssr/dist/cjs/index.js or am I missing some additional Typescript config? I’ve added "esModuleInterop": true, with no change

Here’s the full error I get when testing the Lambda via AWS Console:

{
  "errorType": "Error",
  "errorMessage": "Cannot find module 'vite-plugin-ssr/dist/cjs/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/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:48:73",
    "    at Runtime.__f1 [as handler] (/var/task/__index.js:120:6)",
    "    at Runtime.handleOnce (/var/runtime/Runtime.js:66:25)"
  ]
}

Update: just updated vite-plugin-ssr from 0.2.3 to 0.2.9 and vite from 2.4.2 to 2.5.0 without any luck

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
brilloutcommented, Aug 22, 2021

This doesn’t seem to be related to vite-plugin-ssr.

The error

"Cannot find module ‘vite-plugin-ssr/dist/cjs/node/index.js’

contradicts the fact that the file node_modules/vite-plugin-ssr/dist/cjs/node/index.js does exist.

Something’s wrong with the Pulumi environment. I’d open a GitHub issue over there.

You can try to require('vite-plugin-ssr') directly in your lambda.ts and see if it works. I’d investigate in that direction.

1reaction
jamesladdcommented, Aug 22, 2021

Ah, got it all working with minimal fuss. Happy to share.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting Guide - Pulumi
This guide covers common troubleshooting techniques when using Pulumi, such as tracing, manually editing deployments, and resolving common errors.
Read more >
Things I Wish I Knew Earlier About Pulumi - vsupalov.com
Sometimes, it doesn't completely work out though. If you have parts which rely on each other, but it's not completely obvious to Pulumi,...
Read more >
Infrastructure as Code - An intro - Part 6 - Using Pulumi
And if you can't find a provider for your scenario, you can quite easily ... The tools used for working with Pulumi is...
Read more >
Getting started with New Relic and Pulumi
To use this guide, you should have some basic knowledge of New Relic, Pulumi, and TypeScript. Additionally, since you'll be working with Pulumi...
Read more >
Deploying And Managing Cloud Infrastructure With Pulumi
Show Links: Get Started With Pulumi ... So working at Pulumi, and that is the focus of the show. ... Pulumi doesn't have...
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