Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The Salesforce CLI outputs "DeprecationWarning: The punycode module is deprecated." after every sf command. #2535

Open
catalandres opened this issue Oct 24, 2023 · 17 comments
Labels
area:jsforce bug Issue or pull request that identifies or fixes a bug validated Version information for this issue has been validated

Comments

@catalandres
Copy link

Summary

Running the sf CLI under node v21.0.0 throws out the following warning:

(node:83047) [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

  • Upgrade node to v21.
  • Run any sf command. For example, sf --version.

Expected result

@salesforce/cli/2.13.9 darwin-arm64 node-v21.0.0

Actual result

(node:83092) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
@salesforce/cli/2.13.9 darwin-arm64 node-v21.0.0

System Information

{
  "architecture": "darwin-arm64",
  "cliVersion": "@salesforce/cli/2.13.9",
  "nodeVersion": "node-v21.0.0",
  "osVersion": "Darwin 23.0.0",
  "rootPath": "/opt/homebrew/lib/node_modules/@salesforce/cli",
  "shell": "zsh",
  "pluginVersions": [
    "@oclif/plugin-autocomplete 2.3.9 (core)",
    "@oclif/plugin-commands 2.2.28 (core)",
    "@oclif/plugin-help 5.2.20 (core)",
    "@oclif/plugin-not-found 2.4.3 (core)",
    "@oclif/plugin-plugins 3.9.1 (core)",
    "@oclif/plugin-search 0.0.23 (core)",
    "@oclif/plugin-update 3.2.4 (core)",
    "@oclif/plugin-version 2.0.1 (core)",
    "@oclif/plugin-warn-if-update-available 2.1.1 (core)",
    "@oclif/plugin-which 2.2.34 (core)",
    "@salesforce/cli 2.13.9 (core)",
    "apex 2.3.19 (core)",
    "auth 2.8.20 (core)",
    "data 2.5.16 (core)",
    "deploy-retrieve 1.19.0 (core)",
    "dev 1.2.0 (user)",
    "info 2.6.49 (core)",
    "limits 2.3.38 (core)",
    "login 1.2.35 (core)",
    "marketplace 0.3.0 (core)",
    "org 2.10.12 (core)",
    "schema 2.3.29 (core)",
    "settings 1.4.33 (core)",
    "sobject 0.2.11 (core)",
    "source 2.10.40 (core)",
    "telemetry 2.3.6 (core)",
    "templates 55.5.14 (core)",
    "trust 2.6.18 (core)",
    "user 2.3.36 (core)"
  ]
}

Additional information

Apparently, punycode has been deprecated starting with node v21.

@catalandres catalandres added the investigating We're actively investigating this issue label Oct 24, 2023
@github-actions
Copy link

Thank you for filing this issue. We appreciate your feedback and will review the issue as soon as possible. Remember, however, that GitHub isn't a mechanism for receiving support under any agreement or SLA. If you require immediate assistance, contact Salesforce Customer Support.

@github-actions github-actions bot added the validated Version information for this issue has been validated label Oct 24, 2023
@cristiand391 cristiand391 added bug Issue or pull request that identifies or fixes a bug and removed investigating We're actively investigating this issue labels Oct 24, 2023
@git2gus
Copy link

git2gus bot commented Oct 24, 2023

This issue has been linked to a new work item: W-14355613

@cristiand391
Copy link
Member

Hi @catalandres , we noticed this too a few days ago and tracked it down to 1 dep (whatwg-url):

➜  cli git:(9600617) NODE_OPTIONS='--trace-deprecation' sf config list
(node:67085) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
    at node:punycode:3:9
    at BuiltinModule.compileForInternalLoader (node:internal/bootstrap/realm:392:7)
    at BuiltinModule.compileForPublicLoader (node:internal/bootstrap/realm:328:10)
    at loadBuiltinModule (node:internal/modules/helpers:102:7)
    at Module._load (node:internal/modules/cjs/loader:995:17)
    at Module.require (node:internal/modules/cjs/loader:1229:19)
    at require (node:internal/modules/helpers:177:18)
    at Object.<anonymous> (/Users/cdominguez/.nvm/versions/node/v21.0.0/lib/node_modules/@salesforce/cli/node_modules/whatwg-url/lib/url-state
-machine.js:2:18)
    at Module._compile (node:internal/modules/cjs/loader:1369:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1427:10)

whatwg-url is used by node-fetch v2 (jsforce) and @octokit/request(templates/plugin-templates - via yeoman deps).

for node-fetch there's a PR to bump it but were waiting to get the jsforce test pipeline stable (node-fetch v3 is an ESM package, we'll have to do more changes probably): jsforce/jsforce#1356

for octokit deps we shared this with the IDEx team (they own templates), no ETA yet.

If you are using sf on node v21 and trying to parse CLI output, make sure to only parse stdout (node warning is sent to stderr).

@chechuan
Copy link

This question is bothering me. I searched the internet but couldn't find an answer

@RoboProgrammer69
Copy link

downgrade node to 20.9.0 version

@AmrMohamed001
Copy link

downgrade node to 20.9.0 version

this work👌

@cristiand391
Copy link
Member

@RoboProgrammer69 @AmrMohamed001 are you all downgrading to node 20 because of the warning or are you getting an install error on v21?

@AmrMohamed001
Copy link

@RoboProgrammer69 @AmrMohamed001 are you all downgrading to node 20 because of the warning or are you getting an install error on v21?

Yes as this is unknown warning

@maion308
Copy link

solution that worked for me:
npm install punycode --save

and then in node_modules go to the directory tr46 > index.js

// Replace this:
const punycode = require('punycode');
// With this:
const punycode = require('punycode/');

basically just add a trailing forward slash

@cristiand391
Copy link
Member

@maion308 this warning doesn't break any CLI functionality (if you are parsing CLI output you should always use stdout), why are you swapping the core punycode module?

@wcleveland
Copy link

@cristiand391 He's following the instructions provided by the readme for punycode.

⚠️ Note that userland modules don't hide core modules. For example, require('punycode') still imports the deprecated core module even if you executed npm install punycode. Use require('punycode/') to import userland modules rather than core modules.

@cristiand391
Copy link
Member

please note that this is repo is for Salesforce CLI issues, I think some people is getting here when googling for that warning.

@BianorAraujo
Copy link

solution that worked for me: npm install punycode --save

and then in node_modules go to the directory tr46 > index.js

// Replace this: const punycode = require('punycode'); // With this: const punycode = require('punycode/');

basically just add a trailing forward slash

works like a charm!
thanks

@franciscoxaa
Copy link

I have de issue
node v21.1.0
pnpm 8.10.5
biome ^0.3.3

I run:

`$ biome format --write ./src

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

Does anyone know how to solve it?

@gurleen-codes
Copy link

solution that worked for me: npm install punycode --save
and then in node_modules go to the directory tr46 > index.js
// Replace this: const punycode = require('punycode'); // With this: const punycode = require('punycode/');
basically just add a trailing forward slash

works like a charm! thanks

How did you access the directory tr46? all I see in node_modules is the 'punnycode' folder and the package-lock JSON file.

@catalandres catalandres changed the title DeprecationWarning: The punycode module is deprecated. The Salesforce CLI outputs "DeprecationWarning: The punycode module is deprecated." after every sf command. Nov 16, 2023
@catalandres
Copy link
Author

@cristiand391 Sadly, this thread is getting polluted with comments that are relevant to other projects. I have renamed the issue to make it clear that this is relevant to our tool.

For what it's worth, there is a reasonable temporary solution to this — use nvm to ensure that the default global environment is v20, not v21. And once all the dependencies for @salesforce/cli are v21-compliant this will be a non-issue.

@forcedotcom forcedotcom deleted a comment from BianorAraujo Nov 16, 2023
@cristiand391
Copy link
Member

Locking this issue for a bit, if this warning is affecting scripts parsing Salesforce CLI output see this comment:
#2535 (comment)

@forcedotcom forcedotcom locked as off-topic and limited conversation to collaborators Nov 16, 2023
@forcedotcom forcedotcom unlocked this conversation Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:jsforce bug Issue or pull request that identifies or fixes a bug validated Version information for this issue has been validated
Projects
None yet
Development

No branches or pull requests