xrpl.js
xrpl.js copied to clipboard
DeprecationWarning about `punycode` on Node.js 21
When loading the xrpl module in Node.js 21, a deprecation warning is issued.
(node:99818) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
- node-fetch@2 won't fix this issue, so cross-fetch would have to upgrade to to node-fetch@3
- cross-fetch won't upgrade to node-fetch@3 due to wanting cjs compatibility.
Possible solutions
- Switch to node-fetch@3 and remove cross-fetch. (I haven't really looked at what cross-fetch actually adds, so that might not be an option.)
- Use native Node.js fetch (available from Node.js 18+)
- Use native (or user-supplied) fetch and only load the polyfill if needed
- Include punycode npm module as a dependency and force bundler to use it
- Wait for cross-fetch to fix it (though it doesn't look like they are going to anytime soon)
Upstream issues
lquixada/cross-fetch#177 node-fetch/node-fetch#1797
Dependency tree
xrpl 3.0.0
└─┬ cross-fetch 4.0.0
└─┬ node-fetch 2.7.0
└── whatwg-url 5.0.0
Full stacktrace
(node:99818) [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:398:7)
at BuiltinModule.compileForPublicLoader (node:internal/bootstrap/realm:337:10)
at loadBuiltinModule (node:internal/modules/helpers:104:7)
at Function.Module._load (node:internal/modules/cjs/loader:999:17)
at Module.require (node:internal/modules/cjs/loader:1230:19)
at require (node:internal/modules/helpers:179:18)
at Object. (/opt/workspace/justmoon/dassie/node_modules/.pnpm/[email protected]/node_modules/whatwg-url/lib/url-state-machine.js:2:18)
at Module._compile (node:internal/modules/cjs/loader:1368:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1426:10)
at Module.load (node:internal/modules/cjs/loader:1205:32)
at Function.Module._load (node:internal/modules/cjs/loader:1021:12)
at Module.require (node:internal/modules/cjs/loader:1230:19)
at require (node:internal/modules/helpers:179:18)
at Object. (/opt/workspace/justmoon/dassie/node_modules/.pnpm/[email protected]/node_modules/whatwg-url/lib/URL-impl.js:2:13)
at Module._compile (node:internal/modules/cjs/loader:1368:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1426:10)
at Module.load (node:internal/modules/cjs/loader:1205:32)
at Function.Module._load (node:internal/modules/cjs/loader:1021:12)
at Module.require (node:internal/modules/cjs/loader:1230:19)
at require (node:internal/modules/helpers:179:18)
at Object. (/opt/workspace/justmoon/dassie/node_modules/.pnpm/[email protected]/node_modules/whatwg-url/lib/URL.js:5:14)
at Module._compile (node:internal/modules/cjs/loader:1368:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1426:10)
at Module.load (node:internal/modules/cjs/loader:1205:32)
at Function.Module._load (node:internal/modules/cjs/loader:1021:12)
at Module.require (node:internal/modules/cjs/loader:1230:19)
at require (node:internal/modules/helpers:179:18)
at Object. (/opt/workspace/justmoon/dassie/node_modules/.pnpm/[email protected]/node_modules/whatwg-url/lib/public-api.js:3:15)
at Module._compile (node:internal/modules/cjs/loader:1368:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1426:10)
at Module.load (node:internal/modules/cjs/loader:1205:32)
at Function.Module._load (node:internal/modules/cjs/loader:1021:12)
at Module.require (node:internal/modules/cjs/loader:1230:19)
at require (node:internal/modules/helpers:179:18)
at Object. (/opt/workspace/justmoon/dassie/node_modules/.pnpm/[email protected]/node_modules/node-fetch/lib/index.js:10:33)
at Module._compile (node:internal/modules/cjs/loader:1368:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1426:10)
at Module.load (node:internal/modules/cjs/loader:1205:32)
at Function.Module._load (node:internal/modules/cjs/loader:1021:12)
at Module.require (node:internal/modules/cjs/loader:1230:19)
at require (node:internal/modules/helpers:179:18)
at Object. (/opt/workspace/justmoon/dassie/node_modules/.pnpm/[email protected]/node_modules/cross-fetch/dist/node-ponyfill.js:1:19)
at Module._compile (node:internal/modules/cjs/loader:1368:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1426:10)
at Module.load (node:internal/modules/cjs/loader:1205:32)
at Function.Module._load (node:internal/modules/cjs/loader:1021:12)
at Module.require (node:internal/modules/cjs/loader:1230:19)
at require (node:internal/modules/helpers:179:18)
at Object. (/opt/workspace/justmoon/dassie/node_modules/.pnpm/[email protected]/node_modules/xrpl/src/Wallet/fundWallet.ts:1:1)
at Module._compile (node:internal/modules/cjs/loader:1368:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1426:10)
at Module.load (node:internal/modules/cjs/loader:1205:32)
at Function.Module._load (node:internal/modules/cjs/loader:1021:12)
at Module.require (node:internal/modules/cjs/loader:1230:19)
at require (node:internal/modules/helpers:179:18)
at Object. (/opt/workspace/justmoon/dassie/node_modules/.pnpm/[email protected]/node_modules/xrpl/src/client/index.ts:74:1)
at Module._compile (node:internal/modules/cjs/loader:1368:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1426:10)
at Module.load (node:internal/modules/cjs/loader:1205:32)
at Function.Module._load (node:internal/modules/cjs/loader:1021:12)
at Module.require (node:internal/modules/cjs/loader:1230:19)
at require (node:internal/modules/helpers:179:18)
at Object. (/opt/workspace/justmoon/dassie/node_modules/.pnpm/[email protected]/node_modules/xrpl/src/index.ts:1:1)
Removing support for node 16, which needed to be done anyway. https://github.com/XRPLF/xrpl.js/pull/2678
Thanks for bringing this up and your detailed analysis!
Reopening because this should only be closed when #2678 is merged.
#2678 has been merged