terraform-cdk icon indicating copy to clipboard operation
terraform-cdk copied to clipboard

DeprecationWarning: The `punycode` module is deprecated

Open Rom888 opened this issue 1 year ago • 9 comments

Expected Behavior

No DeprecationWarning

Actual Behavior

There is DepricationWarning cdktf --version

0.20.7
(node:529691) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)

Steps to Reproduce

pnpm add --global [email protected] --ignore-scripts cdktf --version

Versions

language: typescript cdktf-cli: 0.20.7 node: 22.2.0 terraform: 1.8.4 arch: amd64 os: ubuntu 23.10

innerError Error: Cannot find module '../build/Debug/pty.node' Require stack:

  • /home/rom/.local/share/pnpm/global/5/.pnpm/@[email protected]/node_modules/@cdktf/node-pty-prebuilt-multiarch/lib/prebuild-loader.js
  • /home/rom/.local/share/pnpm/global/5/.pnpm/@[email protected]/node_modules/@cdktf/node-pty-prebuilt-multiarch/lib/unixTerminal.js
  • /home/rom/.local/share/pnpm/global/5/.pnpm/@[email protected]/node_modules/@cdktf/node-pty-prebuilt-multiarch/lib/index.js
  • /home/rom/.local/share/pnpm/global/5/.pnpm/[email protected][email protected][email protected]/node_modules/cdktf-cli/bundle/bin/cmds/handlers.js
  • /home/rom/.local/share/pnpm/global/5/.pnpm/[email protected][email protected][email protected]/node_modules/cdktf-cli/bundle/bin/cdktf.js
  • /home/rom/.local/share/pnpm/global/5/.pnpm/[email protected][email protected][email protected]/node_modules/cdktf-cli/bundle/bin/cdktf at Module._resolveFilename (node:internal/modules/cjs/loader:1186:15) at Module._load (node:internal/modules/cjs/loader:1012:27) at Module.require (node:internal/modules/cjs/loader:1271:19) at require (node:internal/modules/helpers:123:16) at Object. (/home/rom/.local/share/pnpm/global/5/.pnpm/@[email protected]/node_modules/@cdktf/node-pty-prebuilt-multiarch/src/prebuild-loader.ts:9:11) at Module._compile (node:internal/modules/cjs/loader:1434:14) at Module._extensions..js (node:internal/modules/cjs/loader:1518:10) at Module.load (node:internal/modules/cjs/loader:1249:32) at Module._load (node:internal/modules/cjs/loader:1065:12) at Module.require (node:internal/modules/cjs/loader:1271:19) { code: 'MODULE_NOT_FOUND', requireStack: [ '/home/rom/.local/share/pnpm/global/5/.pnpm/@[email protected]/node_modules/@cdktf/node-pty-prebuilt-multiarch/lib/prebuild-loader.js', '/home/rom/.local/share/pnpm/global/5/.pnpm/@[email protected]/node_modules/@cdktf/node-pty-prebuilt-multiarch/lib/unixTerminal.js', '/home/rom/.local/share/pnpm/global/5/.pnpm/@[email protected]/node_modules/@cdktf/node-pty-prebuilt-multiarch/lib/index.js', '/home/rom/.local/share/pnpm/global/5/.pnpm/[email protected][email protected][email protected]/node_modules/cdktf-cli/bundle/bin/cmds/handlers.js', '/home/rom/.local/share/pnpm/global/5/.pnpm/[email protected][email protected][email protected]/node_modules/cdktf-cli/bundle/bin/cdktf.js', '/home/rom/.local/share/pnpm/global/5/.pnpm/[email protected][email protected][email protected]/node_modules/cdktf-cli/bundle/bin/cdktf' ] } (node:529917) [DEP0040] DeprecationWarning: The punycode module is deprecated. Please use a userland alternative instead. (Use node --trace-deprecation ... to show where the warning was created) Cannot find module '../build/Release/pty.node' Require stack:
  • /home/rom/.local/share/pnpm/global/5/.pnpm/@[email protected]/node_modules/@cdktf/node-pty-prebuilt-multiarch/lib/prebuild-loader.js
  • /home/rom/.local/share/pnpm/global/5/.pnpm/@[email protected]/node_modules/@cdktf/node-pty-prebuilt-multiarch/lib/unixTerminal.js
  • /home/rom/.local/share/pnpm/global/5/.pnpm/@[email protected]/node_modules/@cdktf/node-pty-prebuilt-multiarch/lib/index.js
  • /home/rom/.local/share/pnpm/global/5/.pnpm/[email protected][email protected][email protected]/node_modules/cdktf-cli/bundle/bin/cmds/handlers.js
  • /home/rom/.local/share/pnpm/global/5/.pnpm/[email protected][email protected][email protected]/node_modules/cdktf-cli/bundle/bin/cdktf.js
  • /home/rom/.local/share/pnpm/global/5/.pnpm/[email protected][email protected][email protected]/node_modules/cdktf-cli/bundle/bin/cdktf Error: Cannot find module '../build/Release/pty.node' Require stack:
  • /home/rom/.local/share/pnpm/global/5/.pnpm/@[email protected]/node_modules/@cdktf/node-pty-prebuilt-multiarch/lib/prebuild-loader.js
  • /home/rom/.local/share/pnpm/global/5/.pnpm/@[email protected]/node_modules/@cdktf/node-pty-prebuilt-multiarch/lib/unixTerminal.js
  • /home/rom/.local/share/pnpm/global/5/.pnpm/@[email protected]/node_modules/@cdktf/node-pty-prebuilt-multiarch/lib/index.js
  • /home/rom/.local/share/pnpm/global/5/.pnpm/[email protected][email protected][email protected]/node_modules/cdktf-cli/bundle/bin/cmds/handlers.js
  • /home/rom/.local/share/pnpm/global/5/.pnpm/[email protected][email protected][email protected]/node_modules/cdktf-cli/bundle/bin/cdktf.js
  • /home/rom/.local/share/pnpm/global/5/.pnpm/[email protected][email protected][email protected]/node_modules/cdktf-cli/bundle/bin/cdktf at Module._resolveFilename (node:internal/modules/cjs/loader:1186:15) at Module._load (node:internal/modules/cjs/loader:1012:27) at Module.require (node:internal/modules/cjs/loader:1271:19) at require (node:internal/modules/helpers:123:16) at Object. (/home/rom/.local/share/pnpm/global/5/.pnpm/@[email protected]/node_modules/@cdktf/node-pty-prebuilt-multiarch/src/prebuild-loader.ts:6:9) at Module._compile (node:internal/modules/cjs/loader:1434:14) at Module._extensions..js (node:internal/modules/cjs/loader:1518:10) at Module.load (node:internal/modules/cjs/loader:1249:32) at Module._load (node:internal/modules/cjs/loader:1065:12) at Module.require (node:internal/modules/cjs/loader:1271:19) Collecting Debug Information... node:internal/process/promises:391 triggerUncaughtException(err, true /* fromPromise */); ^

Error: Cannot find module '../build/Release/pty.node' Require stack:

  • /home/rom/.local/share/pnpm/global/5/.pnpm/@[email protected]/node_modules/@cdktf/node-pty-prebuilt-multiarch/lib/prebuild-loader.js
  • /home/rom/.local/share/pnpm/global/5/.pnpm/@[email protected]/node_modules/@cdktf/node-pty-prebuilt-multiarch/lib/unixTerminal.js
  • /home/rom/.local/share/pnpm/global/5/.pnpm/@[email protected]/node_modules/@cdktf/node-pty-prebuilt-multiarch/lib/index.js
  • /home/rom/.local/share/pnpm/global/5/.pnpm/[email protected][email protected][email protected]/node_modules/cdktf-cli/bundle/bin/cmds/handlers.js
  • /home/rom/.local/share/pnpm/global/5/.pnpm/[email protected][email protected][email protected]/node_modules/cdktf-cli/bundle/bin/cdktf.js
  • /home/rom/.local/share/pnpm/global/5/.pnpm/[email protected][email protected][email protected]/node_modules/cdktf-cli/bundle/bin/cdktf at Module._resolveFilename (node:internal/modules/cjs/loader:1186:15) at Module._load (node:internal/modules/cjs/loader:1012:27) at Module.require (node:internal/modules/cjs/loader:1271:19) at require (node:internal/modules/helpers:123:16) at Object. (/home/rom/.local/share/pnpm/global/5/.pnpm/@[email protected]/node_modules/@cdktf/node-pty-prebuilt-multiarch/src/prebuild-loader.ts:6:9) at Module._compile (node:internal/modules/cjs/loader:1434:14) at Module._extensions..js (node:internal/modules/cjs/loader:1518:10) at Module.load (node:internal/modules/cjs/loader:1249:32) at Module._load (node:internal/modules/cjs/loader:1065:12) at Module.require (node:internal/modules/cjs/loader:1271:19) { code: 'MODULE_NOT_FOUND', requireStack: [ '/home/rom/.local/share/pnpm/global/5/.pnpm/@[email protected]/node_modules/@cdktf/node-pty-prebuilt-multiarch/lib/prebuild-loader.js', '/home/rom/.local/share/pnpm/global/5/.pnpm/@[email protected]/node_modules/@cdktf/node-pty-prebuilt-multiarch/lib/unixTerminal.js', '/home/rom/.local/share/pnpm/global/5/.pnpm/@[email protected]/node_modules/@cdktf/node-pty-prebuilt-multiarch/lib/index.js', '/home/rom/.local/share/pnpm/global/5/.pnpm/[email protected][email protected][email protected]/node_modules/cdktf-cli/bundle/bin/cmds/handlers.js', '/home/rom/.local/share/pnpm/global/5/.pnpm/[email protected][email protected][email protected]/node_modules/cdktf-cli/bundle/bin/cdktf.js', '/home/rom/.local/share/pnpm/global/5/.pnpm/[email protected][email protected][email protected]/node_modules/cdktf-cli/bundle/bin/cdktf' ] }

Node.js v22.2.0

Providers

No response

Gist

No response

Possible Solutions

No response

Workarounds

No response

Anything Else?

No response

References

No response

Help Wanted

  • [ ] I'm interested in contributing a fix myself

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Rom888 avatar Jun 04 '24 12:06 Rom888

That's really serious. Node 21 reached end of life.

benkeil avatar Jun 27 '24 05:06 benkeil

Yeah, this got me too. I had to downgrade to node 20.

eahrend avatar Aug 27 '24 15:08 eahrend

Same behaviour detected on my end.

Reproducible with:

$ cdktf --version
0.20.9
(node:13247) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)

Versions language: typescript cdktf-cli: 0.20.9 node: tested with 22.10.0 and 21.7.3 terraform: 1.9.8 arch: amd64 os: macOS 14.6.1 (23G93)

This is forcing users to rely on older node versions (20.10.0) 😢

RomeroGaliza avatar Oct 29 '24 10:10 RomeroGaliza

The issue is not the warning on the use of punycode but Cannot find module '../build/Debug/pty.node'. @cdktf/node-pty-prebuilt-multiarch does not support node 22 prebuilds, which was added to the upstream repo https://github.com/homebridge/node-pty-prebuilt-multiarch/releases/tag/v0.11.14

troch avatar Nov 05 '24 09:11 troch

I've just upgraded to node js version 22.11.0 which the most recent LTS version. I'm using CDKTF for TypeScript version 0.20.9 and Terraform version 1.9.8. My TypeScript version is 5.6.3, in case that even matters. "@cdktf/provider-aws" is version 19.39.0.

I first got nasty runtime errors as this one, which didn't permit me to continue:

innerError Error: Cannot find module '../build/Debug/pty.node'
Require stack:
- /work/src/node_modules/.pnpm/@[email protected]/node_modules/@cdktf/node-pty-prebuilt-multiarch/lib/prebuild-loader.js
- /work/src/node_modules/.pnpm/@[email protected]/node_modules/@cdktf/node-pty-prebuilt-multiarch/lib/unixTerminal.js
- /work/src/node_modules/.pnpm/@[email protected]/node_modules/@cdktf/node-pty-prebuilt-multiarch/lib/index.js
- /work/src/node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/cdktf-cli/bundle/bin/cmds/handlers.js
- /work/src/node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/cdktf-cli/bundle/bin/cdktf.js
- /work/src/node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/cdktf-cli/bundle/bin/cdktf
    at Function._resolveFilename (node:internal/modules/cjs/loader:1249:15)
    at Function._load (node:internal/modules/cjs/loader:1075:27)
    at TracingChannel.traceSync (node:diagnostics_channel:315:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:218:24)
    at Module.require (node:internal/modules/cjs/loader:1340:12)
    at require (node:internal/modules/helpers:141:16)
    at Object.<anonymous> (/work/src/node_modules/.pnpm/@[email protected]/node_modules/@cdktf/node-pty-prebuilt-multiarch/lib/prebuild-loader.js:10:15)
    at Module._compile (node:internal/modules/cjs/loader:1546:14)
    at Object..js (node:internal/modules/cjs/loader:1689:10)
    at Module.load (node:internal/modules/cjs/loader:1318:32) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/work/src/node_modules/.pnpm/@[email protected]/node_modules/@cdktf/node-pty-prebuilt-multiarch/lib/prebuild-loader.js',
    '/work/src/node_modules/.pnpm/@[email protected]/node_modules/@cdktf/node-pty-prebuilt-multiarch/lib/unixTerminal.js',
    '/work/src/node_modules/.pnpm/@[email protected]/node_modules/@cdktf/node-pty-prebuilt-multiarch/lib/index.js',
    '/work/src/node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/cdktf-cli/bundle/bin/cmds/handlers.js',
    '/work/src/node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/cdktf-cli/bundle/bin/cdktf.js',
    '/work/src/node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/cdktf-cli/bundle/bin/cdktf'
  ]
}
(node:1704) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)

Then I deleted the node_modules directory and reinstalled the package dependencies with pnpm install ("npm ci" or "npm install" should work as well if you use "npm"). This solved the first problem, but now it's showing this warning:

(node:2937) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)

To me it looks as if CDKTF is somewhat behind with keeping its dependencies up-to-date....

I hope the above helps others to resolve the issue as it did for me. It'd be good, though, if the dependencies could be brought up-to-date. Thank you!

ManfredLange avatar Nov 10 '24 04:11 ManfredLange

Unfortunately, this error has re-presented itself.

language: typescript cdktf-cli: 0.20.9 node: 22.12.0 terraform: 1.8.5 arch: amd64 os: MacOS Sonoma 14.3.1

iainbrux avatar Dec 19 '24 17:12 iainbrux

This is still a problem

❯ cdktf init
innerError Error: Cannot find module '../build/Debug/pty.node'

cdktf-cli: 0.20.12 node: v23.6.1 terraform: v1.11.4 arch: linux_amd64 os: Ubuntu

PetteriVaarala avatar May 23 '25 12:05 PetteriVaarala

I also get the Cannot find module '../build/Release/pty.node' error.

I tried the same approach using npm and pnpm. This seems to be particular to pnpm because I tried to install it with npm install --global cdktf-cli@latest, then do npx cdktf get (or any other cdktf command), and it works fine. I tried the same thing with pnpm, pnpm add -g cdktf-cli@latest, then cdktf init --template=typescript --providers=hashicorp/terraform-provider-aws --local (I've the PNPM_HOME + PATH variables configured), and this throws me the error. I also tried to add the cdktf-cli in the package.json and got the same result.

I'm using the latest node LTS v24.11.1 and the latest pnpm 10.19.1-oidc-test.3. So, for now, I'll just use npm/npx till this gets solved on pnpm.

LozanoMatheus avatar Nov 12 '25 12:11 LozanoMatheus

I wonder if the problem with Cannot find module '../build/Release/pty.node error has something to do whether npm build scripts are enabled or not

Installing cdktf-cli with npm_config_ignore_scripts=true npm install -g cdktf-cli@latest results in

❯ cdktf init --local
innerError Error: Cannot find module '../build/Debug/pty.node'
...

However, installing it with npm_config_ignore_scripts=false npm install -g cdktf-cli@latest works

❯ cdktf init --local --template=typescript
Note: By supplying '--local' option you have chosen local storage mode for storing the state of your stack.
This means that your Terraform state file will be stored locally on disk in a file 'terraform.<STACK NAME>.tfstate' in the root of your project.
? Project Name cdktf
...

I've seen this problem before and I think that for pnpm install scripts are disabled by default for dependencies. See https://github.com/pnpm/pnpm/pull/8897

What ignore scripts does is that it prevents any lifecycle hooks for dependencies. There's different ways of ignoring scripts, some more info at https://www.nodejs-security.com/blog/npm-ignore-scripts-best-practices-as-security-mitigation-for-malicious-packages

johanhammar avatar Nov 12 '25 20:11 johanhammar