https://pulumi.com logo
Title
c

careful-book-62830

11/01/2022, 8:37 PM
Hi. I am using ESM instead of CJS in infrastracture code written in Pulumi. But now I have issues with
pulumi
itself. Is there a way to not use
module: "commonjs"
defined in here ?Thank you in advance
Error I am getting
Error: Cannot find module './config.js'
whenever I do import
import * as config from './config.js';
Here is my
Pulumi.yaml
name: test
runtime: nodejs
description: A minimal Azure NextGen TypeScript Pulumi program
main: src/index.ts
options:
  # See <https://github.com/TypeStrong/ts-node/issues/1007>
  nodeargs: "--loader ts-node/esm --no-warnings"
If I change
main
to
dist/index.js
then I get another error from pulumi:
Error [ERR_REQUIRE_ESM]: require() of ES Module/ dist/index.js from /node_modules/@pulumi/pulumi/cmd/run/run.js not supported.
    Instead change the require of index.js in /node_modules/@pulumi/pulumi/cmd/run/run.js to a dynamic import() which is available in all CommonJS modules.
Created an issue for that - https://github.com/pulumi/pulumi/issues/11243#issuecomment-1304852859 But proposed solutions is not a solution TBH