duffelhq/duffel-api-javascript

Error: Cannot find module 'node:http'

jose-dataka opened this issue ยท 4 comments

We cannot import @duffel/api, error: Error: Cannot find module 'node:http'. Node version = 14.18.3. OS = windows 10.

๐Ÿ‘‹ Hello and thanks for reporting this error. What version of @duffel/api are you using?

Hello! We did some investigation on our end and seems when we introduced the new version of node-fetch that caused some issues with the way we are bundling. As a quick fix, could I suggest installing the latest version of node-fetch?

Also worth asking, what's the bundler you are using on your end (there were some issues with Webpack which they fixed in newer versions)?

Edit: we just pushed a new version of the SDK which update how we bundle the core dependencies, please let us know if you still encounter issues after updating it!

Hi there, new error:
(node:16988) UnhandledPromiseRejectionWarning: Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: XXX\node_modules\node-fetch\src\index.js
require() of ES modules is not supported.
require() of XXX\node_modules\node-fetch\src\index.js from XXX\node_modules@duffel\api\dist\index.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename XXX\node_modules\node-fetch\src\index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from XXX\node_modules\node-fetch\package.json.

๐ŸŽ‰ This issue has been resolved in version 1.8.2 ๐ŸŽ‰

The release is available on:

Your semantic-release bot ๐Ÿ“ฆ๐Ÿš€