Open catalandres opened 1 year ago
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.
This issue has been linked to a new work item: W-14355613
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): https://github.com/jsforce/jsforce/pull/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).
This question is bothering me. I searched the internet but couldn't find an answer
downgrade node to 20.9.0 version
downgrade node to 20.9.0 version
this work👌
@RoboProgrammer69 @AmrMohamed001 are you all downgrading to node 20 because of the warning or are you getting an install error on v21?
@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
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
@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?
@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.
please note that this is repo is for Salesforce CLI issues, I think some people is getting here when googling for that warning.
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
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?
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.
@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.
Locking this issue for a bit, if this warning is affecting scripts parsing Salesforce CLI output see this comment: https://github.com/forcedotcom/cli/issues/2535#issuecomment-1777331496
downgrade node to 20.9.0 version
Or use --disable-warning DEP0040
.
Probably not a solution to the punycode deprecation problem, but an alternative option to acheive the exact Expected result from OP problem (node-v21.0.0
without the warning).
The --disable-warning
flag was added in node v21.3.0) and allows suppression of specific warnings.
PS. You can set this flag using the NODE_OPTIONS='--disable-warning DEP0040'
environment varable.
While there may be a better or more correct way to configure this flag (I'd appreciate all the suggestions), but it worked perfectly for my needs: to remove this warning from the CI/CD logs.
So is there an official fix coming for this or is there nothing sf cli
can do here? At some point if we all stop upgrading node
at v20.5.x, won't vscode
or sf
eventually require an upgrade?
@tggagne yes, we have 2 possible workarounds for this before node v22 gets promoted to LTS.
The warning is back :'(
Does this have to do with having included Node v22 LTS in the binary packages starting this week?
Does this have to do with having included Node v22 LTS in the binary packages starting this week?
Yes ^^
I'm seeing this warning too, and it's preventing me from authorizing my org, so I can't retrieve or push any code. I have a fresh Windows install on my work laptop as of 2 weeks ago, but only just got admin permissions so I can install what I need for my developer environment.
I'm running the following versions: VS Code - 1.95.3 SF CLI - 2.66.7 win32-x64 VSCode CLI Integration Extension - v62.5.1
Do we know when a fix for this will be in place @cristiand391? I have run through the various fixes suggested in this thread and on #3111 to no avail.
@catmac42 as workaround, you can downgrade NodeJS to 20.x :)
I'm not a regular NodeJS user so not extremely knowledgeable about this, but I did try downgrading to NodeJS 20.18.0 (just by uninstalling and reinstalling Node to the right version), but the SF CLI seems to think that it's still on v22 when I run sf --version
in the terminal -
Any advice welcome! NB I'm a Windows user so standard nvm isn't an option, and I'm unsure whether there's a "safe" option for Windows.
@catmac42 if you installed SF Cli using windows installer, uninstall it, then reinstall it again with npm install @salesforce/cli -g
:)
@nvuillam For mac, is there a way to get rid of it? or downgrade?. I started experiencing this issue after I wanted to try out the sfdx-hardis extension.
Use Homebrew: brew install sf
.
It takes care of getting the right version of Node.
From: Krishnamurthy @.>
Sent: Wednesday, November 20, 2024 11:50:16 PM
To: forcedotcom/cli @.>
Cc: Andrés Catalán @.>; Mention @.>
Subject: Re: [forcedotcom/cli] The Salesforce CLI outputs "DeprecationWarning: The punycode
module is deprecated." after every sf
command. (Issue #2535)
@nvuillamhttps://github.com/nvuillam For mac, is there a way to get rid of it? or downgrade?
— Reply to this email directly, view it on GitHubhttps://github.com/forcedotcom/cli/issues/2535#issuecomment-2490073422, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAMSTDLOLIM7J7H4WOSMJO32BVRARAVCNFSM6AAAAABP2P6EYGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIOJQGA3TGNBSGI. You are receiving this because you were mentioned.Message ID: @.***>
@nvuillam For mac, is there a way to get rid of it? or downgrade?. I started experiencing this issue after I wanted to try out the sfdx-hardis extension.
Like @catalandres says 😊
Summary
Running the
sf
CLI undernode
v21.0.0 throws out the following warning:Steps To Reproduce
node
to v21.sf
command. For example,sf --version
.Expected result
Actual result
System Information
Additional information
Apparently,
punycode
has been deprecated starting withnode
v21.