Hi, I'm trying to restructure my pulumi repo to co...
# general
c
Hi, I'm trying to restructure my pulumi repo to contain 2 pulumi project with shared custom modules and shared node_modules:
Copy code
├── bastion // pulumi project
├── dliver //pulumi project
├── modules // shared custom modules
├── node_modules // shared node_modules
└── static
bastion/dliver has it's own package.json and pulumi related files, but their node_modules directory is empty, they only using the shared node_modules. It work fine, until I'm trying to use a custom dynamic provider, in that case I got this error during the preview:
Copy code
Diagnostics:
  pulumi:providers:pulumi-nodejs (default):
    error: could not read plugin [/home/ncsibra/.pulumi/bin/pulumi-resource-pulumi-nodejs] stdout: EOF
 
  pulumi:pulumi:Stack (bastion-bastion-dev):
    (node:2514) ExperimentalWarning: queueMicrotask() is experimental.
 
    internal/modules/cjs/loader.js:589
        throw err;
        ^
    Error: Cannot find module '/home/ncsibra/dev/prmrgt-infra/pulumi/bastion/node_modules/@pulumi/pulumi/cmd/dynamic-provider'
        at Function.Module._resolveFilename (internal/modules/cjs/loader.js:587:15)
        at Function.Module._load (internal/modules/cjs/loader.js:513:25)
        at Function.Module.runMain (internal/modules/cjs/loader.js:760:12)
        at startup (internal/bootstrap/node.js:303:19)
        at bootstrapNodeJSCore (internal/bootstrap/node.js:872:3)
The module is in the
/home/ncsibra/dev/prmrgt-infra/pulumi/node_modules/@pulumi/pulumi/cmd/dynamic-provider
directory, not in the
/home/ncsibra/dev/prmrgt-infra/pulumi/bastion/node_modules/@pulumi/pulumi/cmd/dynamic-provider
. Without the dynamic provider, the preview runs fine. I think the problem is not the dynamic provider, because with the old structure(it was one pulumi project, which contained the modules and the node_modules directory too with 1 package.json) everything worked fine. Any idea why it's not find the
@pulumi/pulumi/cmd/dynamic-provider
module, but find everything else in
@pulumi/pulumi
and
@pulumi/aws
?
b
Okay, @cold-coat-35200, this is pretty gross but I think it will unblock you. Can you edit
~/.pulumi/bin/pulumi-resource-pulumi-nodejs
to look like this:
Copy code
#!/bin/sh
node $(node -e "console.log(require.resolve('@pulumi/pulumi/cmd/dynamic-provider'))") $@
The change here is that instead of the relative path, we now use
$(node -e "console.log(require.resolve('@pulumi/pulumi/cmd/dynamic-provider'))")
to construct the path where the dymanic provider's launcher is, which will allow node to use its normal resolution semantics. I believe that will address your issue, based on my local testing it does for me.
I opened https://github.com/pulumi/pulumi/issues/2261 to track making the actual fix, but I'd love to know it addresses your issue first.
c
thanks @bitter-oil-46081, I can check it tomorrow
b
Awesome. Thanks!
c
it solved the issue, at least for the preview, I can't run the actual update right now, but assume it will be ok, thanks @bitter-oil-46081
b
Thanks. I’ll get this into master on Monday.
@cold-coat-35200 Just an FYI, I released a new version of the CLI (0.16.7) that has this fix. Thanks for reporting the issue!
c
thanks @bitter-oil-46081