clients icon indicating copy to clipboard operation
clients copied to clipboard

punycode module deprecated message

Open mphillippiAPG opened this issue 2 years ago • 12 comments

Steps To Reproduce

from terminal on macOS, run any bw command:

bw --version

Expected Result

should only provide the version:

2023.9.1

Actual Result

shows a deprecation warning for punycode in node:

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

Screenshots or Videos

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

Additional Context

No response

Operating System

macOS

Operating System Version

14.0 (23A344)

Shell

Zsh

Build Version

2023.9.1

Issue Tracking Info

  • [X] I understand that work is tracked outside of Github. A PR will be linked to this issue should one be opened to address it, but Bitwarden doesn't use fields like "assigned", "milestone", or "project" to track progress.

mphillippiAPG avatar Oct 24 '23 23:10 mphillippiAPG

As a workaround you can use bw ... 2>/dev/null for the time being, because the noise is written to stderr.

hseeberger avatar Oct 25 '23 06:10 hseeberger

Output of the node --trace-deprecation command

~ node --trace-deprecation /opt/homebrew/bin/bw
(node:32186) [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:101:7)
    at Module._load (node:internal/modules/cjs/loader:1001:17)
    at Module.require (node:internal/modules/cjs/loader:1235:19)
    at require (node:internal/modules/helpers:176:18)
    at Object.<anonymous> (/opt/homebrew/Cellar/bitwarden-cli/2023.9.1/libexec/lib/node_modules/@bitwarden/cli/node_modules/psl/index.js:5:16)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
Usage: bw [options] [command]

tyler-8 avatar Oct 25 '23 16:10 tyler-8

Hi there,

Thank you for your report!

I was able to reproduce this issue, and I have flagged this to our engineering team.

If you wish to add any further information/screenshots/recordings etc., please feel free to do so at any time - our engineering team will be happy to review these.

Thanks once again!

sammbw avatar Oct 27 '23 04:10 sammbw

Downgrade node to 20.9.0 version!

RoboProgrammer69 avatar Oct 28 '23 08:10 RoboProgrammer69

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 avatar Oct 31 '23 00:10 maion308

As a workaround you can use bw ... 2>/dev/null for the time being, because the noise is written to stderr.

So I was able to do this for e.g. bw sync, but not for a command like bw list items --search example.com – which to my understanding seems to imply the latter command writes its regular output to stderr instead of stdout.

Am I right in assuming this as a bug? I am relatively new to shell/command line use, so please do correct me in case I am mistaken.

The reverse also seems to hold:

bw sync 1>/dev/null shows no output (expected); whereas

bw list items --search example.com 1>/dev/null still shows output (both the deprecation message mentioned in this issue, as well as the prompt for entering the master password).

Screenshot attached as a quick demonstration of this.

Screen Shot 2023-10-31 at 10 33 32

lmerz1 avatar Oct 31 '23 09:10 lmerz1

Temporary fix im using:

NODE_OPTIONS="--no-deprecation" bw --version

or add as an env var. export NODE_OPTIONS="--no-deprecation

If you add the env var this will suppress all other depreciation warnings as well. Should probably be removed once this has been fixed.

TheUdK avatar Oct 31 '23 16:10 TheUdK

Temporary fix im using:

NODE_OPTIONS="--no-deprecation" bw --version

or add as an env var. export NODE_OPTIONS="--no-deprecation

If you add the env var this will suppress all other depreciation warnings as well. Should probably be removed once this has been fixed.

Where did you put that exactly?

saidhammane avatar Nov 04 '23 17:11 saidhammane

Temporary fix im using: NODE_OPTIONS="--no-deprecation" bw --version or add as an env var. export NODE_OPTIONS="--no-deprecation If you add the env var this will suppress all other depreciation warnings as well. Should probably be removed once this has been fixed.

Where did you put that exactly?

You can either:

  • if you are using zsh put export NODE_OPTIONS="--no-deprecation it in ~/.zshrc or ~/.zshenv to make it persist in new sessions.
  • put export NODE_OPTIONS="--no-deprecation in the terminal session to make it persist for this session.
  • execute every bw command with the node option as 'prefix' NODE_OPTIONS="--no-deprecation" bw --version

TheUdK avatar Nov 13 '23 07:11 TheUdK

I didn't want to set --no-deprecation globally since I use Node at work. My temp workaround was to make an alias for bw:

# Temp workaround to disable punycode deprecation logging to stderr
# https://github.com/bitwarden/clients/issues/6689
alias bw='NODE_OPTIONS="--no-deprecation" bw'

kschat avatar Jan 05 '24 15:01 kschat

Can we please get some love on this??

Moulick avatar Feb 22 '24 11:02 Moulick

Hi everyone,

This seems to be caused by a transient dependency of jsdom which is required by several features of the CLI. Unfortunately this means we don't have a good way of resolving this until the dependency releases a new version.

In the meanwhile you can avoid the error by using the distributed version of the CLI from our website, by downgrading node or by passing in the --no-deprecation flag to NODE_OPTIONS.

Hinton avatar Feb 23 '24 10:02 Hinton

Related Issues:

  • https://github.com/jsdom/jsdom/issues/3613
  • https://github.com/lupomontero/psl/issues/296
  • https://github.com/salesforce/tough-cookie/pull/346

luckydonald avatar Feb 29 '24 00:02 luckydonald

Not that it is needed, as it has been confirmed by several, but here is another one with the issue on macOS 14.3.1 running Node v21.6.2.

For the time being, I have added an alias per @kschat suggestion, which solves it for me until it has been resolved upstream.

tolecnal avatar Mar 07 '24 19:03 tolecnal

The easiest way to do this is: 1 Let's install the en package (n is its name)) to manage node versions globally: npm install -g n 2 And then, using this package, we switch the node to the version we need: n 20.9.0

navruz8080 avatar Mar 21 '24 19:03 navruz8080

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

Hello,

Could you please explain in detail this part 'and then in node_modules go to the directory tr46 > index.js' ? Thanks.

valorisa avatar Apr 13 '24 12:04 valorisa

To keep the latest version and remove the error messasge, find your installation of bw:

realpath $(which bw)

then go there and up a few directories till you get to the directory with build/, node_modules/, and package*.json files. This is a node project, so run

npm install punycode --save

to install the "userland" version of punycode. Then run

find . -type f -exec grep -H "require(.*punycode" {} \;

to find all the sub-dependencies which require punycode. As @maion308 suggested, making these

require('punycode/')

calls the right version. In this latest version ( 2024.6.0 ) I had to change a few subdependencies until the error went away. Notably I think it's still the tr46 package that's the problem: it's just now a dependent of node-fetch whose version of tr46 (cli/node_modules/node-fetch/node_modules/tr46/index.js) now also needs updating to punycode/ on top of bw-cli's version of tr46 (cli/node_modules/tr46/index.js). Not sure if other changes I made were also necessary. I have at least one instance of some code that says var punycode = require('punycode')(no trailing slash) and the warning message is gone, so maybe ignore those lines.

Servinjesus1 avatar Jun 17 '24 20:06 Servinjesus1

Hello, for me it was file ./node_modules/node-fetch/node_modules/whatwg-url/lib/url-state-machine.js, changing to require('punycode/') fixed the issue.

Also changed:

  • ./node_modules/psl/index.js
  • ./node_modules/node-fetch/node_modules/tr46/index.js

Thanks!

palaueb avatar Jul 04 '24 10:07 palaueb

This just started occurring for me.

bw cli: 2024.6.0 macOS Sonoma 14.5

jzadra avatar Jul 08 '24 19:07 jzadra

I'm also having this issue

bw cli: 2024.6.1 macOS: Sonoma 14.5 (23F79)

gsoneill avatar Aug 03 '24 23:08 gsoneill

Result from the Copy Last Error:

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

The master password is 100% correct. I've copied and pasted it to avoid typos.

Do you have any ideas on when it will be solved? 🙄

kniziol avatar Aug 11 '24 10:08 kniziol