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
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module #11243
Comments
Hi. I was able to reproduce this. The solution would be to copy both Pulumi uses the value provided in the I've opened pulumi/pulumi-hugo#2189 to track clarifying the behavior in the docs as it could be better documented. |
@dixler thanks for the responding, but this is not a solution :) so I don't understand why you just closed the issue When I've used CJS everything worked as expected, so you probably have an issue with your implementation. To support ESM, I need to move files in all infrastructure packages which is not quite a good scenario for my team and me. We use this as a preferred structure for all monorepo packages, and we don't want to use another one for Pulumi only. Please, correct me if I am wrong, but can we find a workaround or fix that? |
My bad, from my limited work with the |
#11045 should hopefully close this. |
@see [github:pulumi#11243](pulumi/pulumi#11243)
I experience this error although The package exports an The package with the adapter is a Javascript Project using err?: Error: Command failed with exit code 255: pulumi up --yes --skip-preview --exec-kind auto.local --stack dev --non-interactive
Updating (dev)
…
pulumi:pulumi:Stack (loremipsum):
error: Running program '/Users/loremipsum/stacks/server/' failed with an unhandled exception:
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/loremipsum/stacks/server/index.js from /Users/loremipsum/node_modules/@pulumi/pulumi/cmd/run/run.js not supported.
…
code: 'ERR_REQUIRE_ESM' I use es modules throughout the package, there is no
name: loremipsum
runtime:
name: nodejs
options:
typescript: false
description: AWS infrastructure for a sveltekit app
{
"name": "@lorem/sveltekit-adapter",
"version": "0.0.0",
"main": "./index.js",
"type": "module",
"dependencies": {
"@pulumi/command": "^0.7.2",
"@pulumi/pulumi": "^3.62.0",
"tsconfig": "^0.0.0"
}
} |
What happened?
I am migrating my project from CJS to ESM. I put
type: "module"
to projectpackage.json
and now trying to runpulumi preview
to test everything.Here is my
Pulumi.yaml
:Folder structure:
Full error that I am getting:
If I move everything from
src
folder to the root level and removemain
fromPulumi.yaml
everything works fine.pulumi version:
v3.45.0
Steps to reproduce
Please, see above
Expected Behavior
Pulumi + Typescript creates resources and works well with ESM
Actual Behavior
Pulumi + Typescript don't create resources don't work with ESM
Output of
pulumi about
Additional context
config.ts
file:index.ts
file:No response
Contributing
Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).
The text was updated successfully, but these errors were encountered: