I'm trying to use Asciinema with Svelte. When I try to import * as AsciinemaPlayer from 'asciinema-player';, I get an import error, which Node suggests may be due to an incorrect configuration.
To Reproduce
Steps to reproduce the behavior:
npm i -D asciinema-player
import * as AsciinemaPlayer from 'asciinema-player'; within my Svelte project
(node:118652) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
11:18:02 pm [vite] Error when evaluating SSR module /src/components/AsciinemaPlayer.svelte: failed to import "asciinema-player"
|- /home/migue/Source/portfolio/node_modules/asciinema-player/dist/index.js:4719
export { create };
^^^^^^
SyntaxError: Unexpected token 'export'
at internalCompileFunction (node:internal/vm:73:18)
at wrapSafe (node:internal/modules/cjs/loader:1178:20)
at Module._compile (node:internal/modules/cjs/loader:1220:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12)
at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:169:29)
at ModuleJob.run (node:internal/modules/esm/module_job:194:25)
Expected behavior
I am able to import and use the Asciinema player.
Versions:
OS: Fedora 40
Browser: Firefox Developer Edition 127.0b2
Node: v18.18.2
asciinema player: 3.7.1
Additional context
Note Node's suggestion to fix the issue:
Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
I have checked, and your package.json does not have a "type": "module" entry in it, which would explain why the export statement is failing.
Describe the bug
I'm trying to use Asciinema with Svelte. When I try to
import * as AsciinemaPlayer from 'asciinema-player';
, I get an import error, which Node suggests may be due to an incorrect configuration.To Reproduce Steps to reproduce the behavior:
npm i -D asciinema-player
import * as AsciinemaPlayer from 'asciinema-player';
within my Svelte projectExpected behavior I am able to import and use the Asciinema player.
Versions:
Additional context
Note Node's suggestion to fix the issue:
I have checked, and your
package.json
does not have a"type": "module"
entry in it, which would explain why theexport
statement is failing.