Anyone's got a Pulumi project working in a monorepo (turbo) using `pnpm` ? I know the doc mentions i...
d
Anyone's got a Pulumi project working in a monorepo (turbo) using
pnpm
? I know the doc mentions it supports
npm
and
yarn
and no mention of
pnpm
- but I am still trying 🙃. I am new with Pulumi, trying to set-up a basic project, it all installs fine but there seems to be some node modules linking issues. Whenever i try to execute a basic script (via the pulumi CLI or simply just running it with
node
, I am facing some package export issues. I tried switching node versions, I tried using dynamic
import()
,
commonjs
vs
module
- always end up with the same error - I am at a loss here. That
fs-minipass
package seems to be the root of the issue.
Copy code
error: Running program '/Users/simonbuisson/Documents/dev/carebrain/monorepo/tooling/IaC/index.ts' failed with an unhandled exception:
    TypeError: Class extends value undefined is not a constructor or null
        at Object.<anonymous> (/Users/simonbuisson/Documents/dev/carebrain/monorepo/node_modules/fs-minipass/lib/index.js:136:4)
        at Module._compile (node:internal/modules/cjs/loader:1730:14)
        at node:internal/modules/cjs/loader:1895:10
        at Object.require.extensions.<computed> [as .js] (/Users/simonbuisson/Documents/dev/carebrain/monorepo/node_modules/ts-node/src/index.ts:1608:43)
        at Module.load (node:internal/modules/cjs/loader:1465:32)
        at Function._load (node:internal/modules/cjs/loader:1282:12)
        at TracingChannel.traceSync (node:diagnostics_channel:322:14)
        at wrapModuleLoad (node:internal/modules/cjs/loader:235:24)
        at Module.require (node:internal/modules/cjs/loader:1487:12)
        at require (node:internal/modules/helpers:135:16)
b
I'm successfully using Pulumi in a turbo monorepo with pnpm...
I've been using
tsx
as the loader...
Copy code
runtime:
  name: nodejs
  options:
    packagemanager: pnpm
    nodeargs: "--import tsx"
d
Thanks for the pointer Justin, will give this a try !
So using tsx as loader didnt fix my issue. I am going to put my fix here if anyone faces the same issue. It was caused by
node_modules
being hoisted. Updated the
.npmrc
in my monorepo to not hoist the node_modules in the folder where I have my pulumi project (
/tooling/iac
)
Copy code
node-linker=hoisted
hoist-pattern[]=*
hoist-pattern[]=@!(tooling/iac/**)
👍 1
b
Nice find, confirmed that is also my configuration (not hoisted)