-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
Crypto warnings coming up for import crypto from 'crypto'
#23203
Comments
//cc @nodejs/modules |
The fix for this so far is to make those deprecated APIs non-enumerable. This also means they aren't available to named exports. |
I prefer @jdalton's solution. Hiding the deprecation warnings might result in people unknowingly using deprecated APIs. |
Since it is a deprecated API, a deprecation warning is printed when loading crypto module from ESM. Making it non enumerable remove the deprecation warning and make the API non-available to named imports. Fixes: nodejs#23203
Since it is a deprecated API, a deprecation warning is printed when loading crypto module from ESM. Making it non enumerable remove the deprecation warning and make the API non-available to named imports. PR-URL: nodejs#23222 Fixes: nodejs#23203 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
will this fix be backported to v10 or v11 ? |
It can't be backported, its semver-major (breaks the API): |
FYI for those who googled into this issue in the future: if you have import * as crypto from "crypto"; and see these warnings, just replace it with import crypto from "crypto"; This helped in my case (node v9.11.2). |
FYI for those who googled into this issue in the future using Typescript: if you have import crypto, {randomBytes} from "crypto";
const randomBytesAsync = promisify(randomBytes);
const pseudoRandomBytesAsync = promisify(crypto.pseudoRandomBytes); and see these warnings, just replace it with either import {randomBytes, pseudoRandomBytes} from "crypto";
const randomBytesAsync = promisify(randomBytes);
const pseudoRandomBytesAsync = promisify(pseudoRandomBytes); or import crypto from "crypto";
const randomBytesAsync = promisify(crypto.randomBytes);
const pseudoRandomBytesAsync = promisify(crypto.pseudoRandomBytes); When using a mix of default and selective import, Typescript will transpile it to * import causing your code to access deprecated fields. |
When using `import * from crypto` get warings like > DeprecationWarning: crypto.DEFAULT_ENCODING is deprecated See nodejs/node#23203 (comment)
* Add refrigerator support * Add method getDevice * Add dishwasher * Refactoring * Add dryer * Add washer * Fixed import paths in devices/ac * Fix Celsius to Fahrenheit convertion table * Fixed swing mode so they are mapped to the right enum. * Add the ACDevice to the client loader * Small fix * Update ac.ts * Update client.ts * All parameters to lowercase * Add multi language support * Fix for comments * Add localization support * Update README.md * Add tslint * Refactoring * Some fixes for tslint * Add devices to export * Fix "[DEP0091] DeprecationWarning: crypto.DEFAULT_ENCODING is deprecated." (nodejs/node#23203) * Add more options for RefrigeratorDevice * Small fix for washer * Add parameter --token into cli * Add method setOn * Add OnOffEnum * Update README.md * Fix for lookupReference Add more device types Co-authored-by: Tom Green <tomgreen981111@yahoo.com>
* Add refrigerator support * Add method getDevice * Add dishwasher * Refactoring * Add dryer * Add washer * Fixed import paths in devices/ac * Fix Celsius to Fahrenheit convertion table * Fixed swing mode so they are mapped to the right enum. * Add the ACDevice to the client loader * Small fix * Update ac.ts * Update client.ts * All parameters to lowercase * Add multi language support * Fix for comments * Add localization support * Update README.md * Add tslint * Refactoring * Some fixes for tslint * Add devices to export * Fix "[DEP0091] DeprecationWarning: crypto.DEFAULT_ENCODING is deprecated." (nodejs/node#23203) * Add more options for RefrigeratorDevice * Small fix for washer * Add parameter --token into cli * Add method setOn * Add OnOffEnum * Update README.md * Fix for lookupReference Add more device types * Fix for lookupEnum Co-authored-by: Tom Green <tomgreen981111@yahoo.com>
This avoid an unwanted deprecation notice. See nodejs/node#23203 for more details. Ticket: BG-22502
When running Node with --experimental-modules I'm getting warnings on crypto:
test.mjs
Ideally we should hide deprecation warnings that are output during named exports population for core modules.
//cc @node/modules @devsnek
The text was updated successfully, but these errors were encountered: