You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First off, this is a wonderful little library, great work!
I'm using ESM with Node 18 (same result on latest Node 22) and using import fails on import fetch from 'isomorphic-unfetch';. I've locally resolved this by renaming the psn-api.esm.js file to psn-api.mjs and adjusting the package.json accordingly.
Here's the original error, for context:
[Named export 'exchangeCodeForAccessToken' not found. The requested module 'psn-api' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from 'psn-api';
const { exchangeNpssoForCode, exchangeCodeForAccessToken, getUserTitles } = pkg;
And using that suggestion…
Cannot use import statement outside a module (via SyntaxError)
Original error stack trace: .../node_modules/psn-api/dist/psn-api.esm.js:1
import fetch from 'isomorphic-unfetch';
^^^^^^
I'm not sure how this is handled as it seems automated by the tsconfig.json file and I don't use TypeScript, so I'm a little out of my depth. However I imagine that perhaps it is an option set by compilerOptions.module, though looking at some documentation, this might be because this library supports older versions of Node (I see references to node16).
I'm trying to go "all in" on ESM in my project, and would love to be able to leverage this library without any weird hacks, but I understand if this would be a breaking change that cannot be implemented quickly.
I would also be happy to submit a pull request if somebody can point me in the right direction to push this along — or if my previous point about a breaking change is relevant, I'd probably fork this repo for my own use with the update, and patiently wait for an official release.
Hi there,
First off, this is a wonderful little library, great work!
I'm using ESM with Node 18 (same result on latest Node 22) and using
import
fails onimport fetch from 'isomorphic-unfetch';
. I've locally resolved this by renaming thepsn-api.esm.js
file topsn-api.mjs
and adjusting thepackage.json
accordingly.Here's the original error, for context:
And using that suggestion…
I'm not sure how this is handled as it seems automated by the
tsconfig.json
file and I don't use TypeScript, so I'm a little out of my depth. However I imagine that perhaps it is an option set bycompilerOptions.module
, though looking at some documentation, this might be because this library supports older versions of Node (I see references tonode16
).I'm trying to go "all in" on ESM in my project, and would love to be able to leverage this library without any weird hacks, but I understand if this would be a breaking change that cannot be implemented quickly.
I would also be happy to submit a pull request if somebody can point me in the right direction to push this along — or if my previous point about a breaking change is relevant, I'd probably fork this repo for my own use with the update, and patiently wait for an official release.
Let me know if I can help, and thank you!
Chris
EDIT: For now I will use this workaround:
The text was updated successfully, but these errors were encountered: