Hey.. I'm tryihng to install a Terraform provider ...
# general
g
Hey.. I'm tryihng to install a Terraform provider in my Typescript Pulumi project and we're getting this error:
Copy code
pulumi package add terraform-provider vantage-sh/vantage
warning: <nil>: #/functions/pulumi:providers:vantage%2FterraformConfig/inputs/properties/__self__/$ref: reference to provider resource '/resources/pulumi:providers:vantage' is deprecated, use '#/provider' instead; 
warning: <nil>: #/functions/pulumi:providers:vantage%2FterraformConfig/inputs/properties/__self__/$ref: reference to provider resource '/resources/pulumi:providers:vantage' is deprecated, use '#/provider' instead; 
Successfully generated a Nodejs SDK for the vantage package at /Users/diranged/git/nextdoor/infra-observability/sdks/vantage
npm warn ERESOLVE overriding peer dependency
npm warn While resolving: jest-config@30.0.5
npm warn Found: @types/node@18.19.123
npm warn node_modules/@jest/core/node_modules/jest-config/node_modules/@types/node
npm warn
npm warn Could not resolve dependency:
npm warn peerOptional @types/node@"*" from jest-config@30.0.5
npm warn node_modules/@jest/core/node_modules/jest-config
npm warn   jest-config@"30.0.5" from @jest/core@30.0.5
npm warn   node_modules/@jest/core
npm error code 1
npm error path ..../sdks/vantage
npm error command failed
npm error command sh -c node ./scripts/postinstall.js
npm error Command failed: tsc: ../../node_modules/jest-mock/build/index.d.ts(8,21): error TS2726: Cannot find lib definition for 'esnext.disposable'.
I haven't yet tracked down what is failing... ive tried upgrading to Node 24, and we are usiing Typescript 5.9... all of our dependencies are updated to the latest versions. Any thoughts?
I see the library file in my node_modules:
Copy code
% find node_modules -name lib.esnext.disposable.d.ts
node_modules/typescript/lib/lib.esnext.disposable.d.ts
w
Could you paste the contents of
sdks/vantage/package.json
here?
I wonder if you might need
@types/node@24
also? I am a bit confused why it’s poking through jest-mocks while compiling the code for the SDK though 🤔
g
Hey! So I just made some progress... it seems like the
sdks/vantage/package.json
gets set up with:
Copy code
"devDependencies": {
        "@types/node": "^18",
        "typescript": "^4.3.5"
    },
It seems to me that it's installing typescript 4.3.5 (because of the very explicit version pinning... as opposed to something like
^4
... ), which doesn't have
esnext.disposable
in it at all.
here's the entire
sdks/vantage/package.json
that gets generated
Copy code
{
  "name": "@pulumi/vantage",
  "version": "0.1.62",
  "description": "A Pulumi provider dynamically bridged from vantage.",
  "repository": "<https://github.com/vantage-sh/terraform-provider-vantage>",
  "main": "bin/index.js",
  "scripts": {
    "build": "tsc",
    "postinstall": "node ./scripts/postinstall.js"
  },
  "dependencies": {
    "@pulumi/pulumi": "^3.142.0",
    "async-mutex": "^0.5.0"
  },
  "devDependencies": {
    "@types/node": "^18",
    "typescript": "^4.3.5"
  },
  "pulumi": {
    "resource": true,
    "name": "terraform-provider",
    "version": "0.13.0",
    "parameterization": {
      "name": "vantage",
      "version": "0.1.62",
      "value": "eyJyZW1vdGUiOnsidXJsIjoicmVnaXN0cnkub3BlbnRvZnUub3JnL3ZhbnRhZ2Utc2gvdmFudGFnZSIsInZlcnNpb24iOiIwLjEuNjIifX0="
    }
  }
}
Copy code
% cd sdks/vantage 
% yarn install
yarn install v1.22.22
warning package.json: No license field
info No lockfile found.
warning @pulumi/vantage@0.1.62: No license field
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...
success Saved lockfile.
$ node ./scripts/postinstall.js
Command failed: tsc: ../../node_modules/expect/node_modules/jest-mock/build/index.d.ts(8,21): error TS2726: Cannot find lib definition for 'esnext.disposable'.


error Command failed with exit code 1.
info Visit <https://yarnpkg.com/en/docs/cli/install> for documentation about this command.
% ./node_modules/.bin/tsc --version
Version 4.9.5
w
Mmmm are you on a CLI version 3.189 or older? There was a slight change in https://github.com/pulumi/pulumi/pull/20272 to how the generated SDK depends on TypeScript in 3.190. It would be good to try with that version.
g
lemme check
ok we are..
Copy code
% pulumi version
v3.188.0
(updating, will retry)
w
Cool! What’s still confusing me though is that the postinstall script tries to compile something from
../../
. Do you have a setup with workspaces? I just tried
pulumi new typescript
and then
pulumi package add terraform-provider vantage-sh/vantage
and that works. Hopefully the latest CLI version helps here, but there might still be something else going on.
g
ok upgraded, but no change in the behavior
w
sadness
g
Let me try a new test project.. That expects me to have some pulumi api token.. so skipping that for a sec.
So we're using Projen to manage our Pulumi project. Is there something specific in the root
tsconfig.json
you'd like to see that might help here?
Does it matter that I'm using
nodenv
for node?
w
I wouldn’t think so
g
Copy code
% cat tsconfig.json 
// ~~ Generated by projen. To modify, edit .projenrc.ts and run "npx projen".
{
  "compilerOptions": {
    "rootDir": "src",
    "outDir": "lib",
    "alwaysStrict": true,
    "declaration": true,
    "esModuleInterop": true,
    "experimentalDecorators": true,
    "inlineSourceMap": true,
    "inlineSources": true,
    "lib": [
      "es2020"
    ],
    "module": "CommonJS",
    "noEmitOnError": false,
    "noFallthroughCasesInSwitch": true,
    "noImplicitAny": true,
    "noImplicitReturns": true,
    "noImplicitThis": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "resolveJsonModule": true,
    "strict": true,
    "strictNullChecks": true,
    "strictPropertyInitialization": true,
    "stripInternal": true,
    "target": "ES2020"
  },
  "include": [
    "src/**/*.ts"
  ],
  "exclude": []
}
this is our root level tsconfig.json
w
sdk/vantage
has its own
tsconfig.json
, so that should be standalone and not take that into account, or does it? Not entirely sure how this sort of nesting works in typescript
g
here's the package.json
Copy code
% cat package.json 
{
  "name": "...",
  "scripts": {
    "build": "npx projen build",
    "ca:login": "npx projen ca:login",
    "clobber": "npx projen clobber",
    "compile": "npx projen compile",
    "default": "npx projen default",
    "eject": "npx projen eject",
    "eslint": "npx projen eslint",
    "package": "npx projen package",
    "post-compile": "npx projen post-compile",
    "post-upgrade": "npx projen post-upgrade",
    "pre-compile": "npx projen pre-compile",
    "test": "npx projen test",
    "test:watch": "npx projen test:watch",
    "upgrade": "npx projen upgrade",
    "watch": "npx projen watch",
    "projen": "npx projen"
  },
  "devDependencies": {
    "@types/jest": "^30.0.0",
    "@types/node": "^18",
    "@typescript-eslint/eslint-plugin": "^8",
    "@typescript-eslint/parser": "^8",
    "constructs": "^10.0.0",
    "eslint": "^9",
    "eslint-config-prettier": "^10.1.8",
    "eslint-import-resolver-typescript": "^4.4.4",
    "eslint-plugin-import": "^2.32.0",
    "eslint-plugin-prettier": "^5.5.4",
    "jest": "^30.0.5",
    "jest-junit": "^16",
    "prettier": "^3.6.2",
    "projen": "^0",
    "ts-jest": "^29.4.1",
    "ts-node": "^10.9.2",
    "typescript": "^5.9.2"
  },
  "dependencies": {
    "@lbrlabs/pulumi-grafana": "^0",
    "@....<internal pkg>": "latest",
    "@pulumi/datadog": "^4",
    "@pulumi/pagerduty": "^4",
    "@pulumi/pulumi": "^3",
    "@slack/web-api": "^7",
    "@types/async-lock": "^1",
    "@types/js-yaml": "^4",
    "async-lock": "^1",
    "js-yaml": "^4",
    "projen": "^0",
    "re2js": "0",
    "ts-deepmerge": "^7"
  },
  "engines": {
    "node": ">= 24.2.0"
  },
  "license": "Apache-2.0",
  "publishConfig": {
    "access": "public"
  },
  "version": "0.0.0",
  "jest": {
    "coverageProvider": "babel",
    "coverageThreshold": {
      "global": {
        "branches": 100,
        "functions": 100,
        "lines": 100,
        "statements": 100
      }
    },
    "testMatch": [
      "<rootDir>/@(src|test)/**/*(*.)@(spec|test).ts?(x)",
      "<rootDir>/@(src|test)/**/__tests__/**/*.ts?(x)",
      "<rootDir>/@(projenrc)/**/*(*.)@(spec|test).ts?(x)",
      "<rootDir>/@(projenrc)/**/__tests__/**/*.ts?(x)"
    ],
    "clearMocks": true,
    "collectCoverage": true,
    "coverageReporters": [
      "json",
      "lcov",
      "clover",
      "cobertura",
      "text"
    ],
    "coverageDirectory": "coverage",
    "coveragePathIgnorePatterns": [
      "/node_modules/"
    ],
    "testPathIgnorePatterns": [
      "/node_modules/"
    ],
    "watchPathIgnorePatterns": [
      "/node_modules/"
    ],
    "reporters": [
      "default",
      [
        "jest-junit",
        {
          "outputDirectory": "test-reports"
        }
      ]
    ],
    "transform": {
      "^.+\\.[t]sx?$": [
        "ts-jest",
        {
          "tsconfig": "tsconfig.dev.json"
        }
      ]
    }
  },
  "//": "~~ Generated by projen. To modify, edit .projenrc.ts and run \"npx projen\"."
}
w
Does
sdks/vantage/node_modules/typescript
exist? and what version is in
package.json
. I would expect that to be
4.3
g
w
sdks/vantage
is meant to be its own thing, that’s compiled down to Javascript via postinstall
using its own typescript dependency (4.3.5) in this case
g
ls sdks/vantage/node_modules/typescript
does not work - when i run the
pulumi package add terraform-provider vantage-sh/vantage
it jumps into running
tsc
.. but that happens before it tries a yarn install itseems?
oh... so this is some kind of dependency polution.. the
sdks/vantage
directory is ending up using
tsc
from the top level package... but then breaking..
w
Something like that I think
Can you
cd sdks/vantage && yarn install && yarn run postinstall
? Also checking, are you using yarn or npm or some other package manager (they should all work)
oh you did that above already
Copy code
$ node ./scripts/postinstall.js
Command failed: tsc: ../../node_modules/expect/node_modules/jest-mock/build/index.d.ts(8,21): error TS2726: Cannot find lib definition for 'esnext.disposable'.
This is the part that i don’t understand. What makes it look at
../../node_modules/….
?
g
Copy code
% cd sdks/vantage && yarn install && yarn run postinstall
yarn install v1.22.22
warning package.json: No license field
warning @pulumi/vantage@0.1.62: No license field
[1/4] 🔍  Resolving packages...
success Already up-to-date.
$ node ./scripts/postinstall.js
Failed to run 'tsc' {
  stdout: "../../node_modules/expect/node_modules/jest-mock/build/index.d.ts(8,21): error TS2726: Cannot find lib definition for 'esnext.disposable'.\n",
  stderr: ''
}
error Command failed with exit code 1.
info Visit <https://yarnpkg.com/en/docs/cli/install> for documentation about this command.
i agree, its strange to me that its going up the directory structure... im not SUPER familiar with nested typescript packages here, so this is a little out of my normal depth
w
ls sdks/vantage/node_modules/typescript
does not work - when i run the
pulumi package add terraform-provider vantage-sh/vantage
it jumps into running
tsc
.. but that happens before it tries a yarn install itseems?
That is weird too. What is supposed to happen is that
pulumi package add …
first generates the SDK (this part works), then it calls something like
npm add @pulumi/vantage@file:./sdks/vantage
. This
npm add
call (or yarn or pnpm or … depending on the configured package manager) will then execute the postinstall script during intsallation, which compiles the sdk to javascript.
But somehow in your case
sdks/vantage/node_modules/typescript
does not seem to exist 🤔
g
What is supposed to do the
yarn install
inside the
sdks/vantage
directory?
w
ah yeah
pulumi package add
should run that that too
let me check the code quick
g
either way.. in order for
yarn install
in the
sdks/vantage
directory to work, i have to patch the
package.json
and change the typescript dependency version... so there is clearly something happening where its leveraging the parent-level stuff. I wonder if that's due to
nodenv
in someway.
you know though.. i was able to manually patch the package.json file.. then manually run the yarn install, then manually run npm add... and that all worked..
w
ok no
pulumi package add
does not run
yarn install
or similar, it just runs
yarn add @pulumi/vantage@file:./sdks/vantage
to link it into the project. If it wants a different version of tsc, it will install that into
sdks/vantage/node_modules
to disambiguate from the toplevel one.
I’ll play around abit with a local project using a similar package.json to what you have to figure this out.
Ok just grabbing the devDeps from your package.json and I can reproduce the issue. I’ll try to find some time to dig into this this week, we must be doing something dumb or wrong with how we compile the generated SDK.
g
Thank you! I appreciate you helping out...
for what its worth, i use projen for all of our typescript projects... and it definitely sometimes has some weirdnesses you have to work around..
w
Ok I understood what’s happening. By default typescript will use all
@types/...
packages it finds, but some of these might not be compatible with the typescript version used by the SDK, leading to the error. To make this work, we need to change our
postinstall.js
script to pass the
--types
flag to
tsc
, so that we can control which
@types/...
packages it should use (just the ones the SDK depends on, for example
tsc --types node
). I should be able to get a PR in for this week’s release. In the meantime, you could remove
@types/jest
or maybe downgrading to
@types/jest 29
, but either of that might not be possible, depending on your jest usage in the project.
g
Thank you for the deep dive! I was able to make it work by manually runnin the commands that the
pulumi
cli was going to do anyways... so right now I am fine to experiment. Is there a github issue to track this issue so I can subscribe?
w
g
@white-camera-67848 hmm i was able to download the new binary from the PR (that's a cool feature btw) - and it actually doesn't help with the original problem..
Copy code
% /Users/diranged/.pulumi/bin/pulumi version && /Users/diranged/.pulumi/bin/pulumi package add terraform-provider vantage-sh/vantage
v3.192.0-alpha.1756194825
warning: using pulumi-language-nodejs from $PATH at /opt/homebrew/bin/pulumi-language-nodejs expected /Users/diranged/.pulumi/bin/pulumi-language-nodejs
warning: <nil>: #/functions/pulumi:providers:vantage%2FterraformConfig/inputs/properties/__self__/$ref: reference to provider resource '/resources/pulumi:providers:vantage' is deprecated, use '#/provider' instead; 
warning: <nil>: #/functions/pulumi:providers:vantage%2FterraformConfig/inputs/properties/__self__/$ref: reference to provider resource '/resources/pulumi:providers:vantage' is deprecated, use '#/provider' instead; 
Successfully generated a Nodejs SDK for the vantage package at .../sdks/vantage
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: jest-config@30.0.5
npm WARN Found: @types/node@24.3.0
npm WARN node_modules/jest-config/node_modules/@types/node
npm WARN 
npm WARN Could not resolve dependency:
npm WARN peerOptional @types/node@"*" from jest-config@30.0.5
npm WARN node_modules/jest-config
npm WARN   jest-config@"30.0.5" from jest-cli@30.0.5
npm WARN   node_modules/jest-cli
npm ERR! code 1
npm ERR! path /..../sdks/vantage
npm ERR! command failed
npm ERR! command sh -c node ./scripts/postinstall.js
npm ERR! Failed to run 'tsc' {
npm ERR!   stdout: "../../node_modules/jest-mock/build/index.d.ts(8,21): error TS2726: Cannot find lib definition for 'esnext.disposable'.\n",
npm ERR!   stderr: ''
npm ERR! }
w
You also need to use the matching
pulumi-language-nodejs
. The
pulumi
binary starts up the nodejs language plugin to run the code generation.
g
Ah yeah I don't know how to do that yet... are the instructions easy?
w
Download the binary for
pulumi-language-nodejs
and place it next to the
pulumi
binary. I think you could just install the latest
dev
releases https://www.pulumi.com/docs/iac/download-install/#installing-dev-releases
g
im testing the dev installer.. but where would i find the dev-binary of pulumi-language-nodejs?
w
The dev installer will install it next to
pulumi
After running
Copy code
curl -fsSL <https://get.pulumi.com> | sh -s -- --version dev
it should be in
~/.pulumi/bin
g
so i see that the timestamps got updated .. but it doesn't change the behavior of the code.. so im not sure if it's really updating that library or not.
Copy code
% cat ./bin/pulumi-resource-pulumi-nodejs

#!/bin/sh
PULUMI_DYNAMIC_PROVIDER_SCRIPT_PATH=$(node -e "console.log(require.resolve('@pulumi/pulumi/cmd/dynamic-provider'))")
if [ ! -z "$PULUMI_DYNAMIC_PROVIDER_SCRIPT_PATH" ]; then
    node "$PULUMI_DYNAMIC_PROVIDER_SCRIPT_PATH" $@
fi
I'm not sure where the pulumi provider is being loaded from:
Copy code
% find . 
.
./dynamic_tf_plugins
./dynamic_tf_plugins/registry.opentofu.org
./dynamic_tf_plugins/registry.opentofu.org/vantage-sh
./dynamic_tf_plugins/registry.opentofu.org/vantage-sh/vantage
./dynamic_tf_plugins/registry.opentofu.org/vantage-sh/vantage/0.1.62
./dynamic_tf_plugins/registry.opentofu.org/vantage-sh/vantage/0.1.62/darwin_arm64
./dynamic_tf_plugins/registry.opentofu.org/vantage-sh/vantage/0.1.62/darwin_arm64/LICENSE
./dynamic_tf_plugins/registry.opentofu.org/vantage-sh/vantage/0.1.62/darwin_arm64/README.md
./dynamic_tf_plugins/registry.opentofu.org/vantage-sh/vantage/0.1.62/darwin_arm64/terraform-provider-vantage_v0.1.62
./bin
./bin/pulumi-resource-pulumi-python
./bin/pulumi-language-nodejs
./bin/pulumi-resource-pulumi-nodejs
./bin/pulumi-analyzer-policy-python
./bin/pulumi-language-go
./bin/pulumi-language-python
./bin/pulumi-language-java
./bin/pulumi-analyzer-policy
./bin/pulumi-watch
./bin/pulumi-language-yaml
./bin/pulumi-language-dotnet
./bin/pulumi
./bin/pulumi-language-python-exec
./plugins
./plugins/resource-terraform-provider-v0.13.0.lock
./plugins/resource-terraform-provider-v0.13.0
./plugins/resource-terraform-provider-v0.13.0/LICENSE
./plugins/resource-terraform-provider-v0.13.0/CHANGELOG_OLD.md
./plugins/resource-terraform-provider-v0.13.0/README.md
./plugins/resource-terraform-provider-v0.13.0/pulumi-resource-terraform-provider