Skip to content
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

Help importing project into node js project #69

Open
velara3 opened this issue Nov 29, 2022 · 2 comments
Open

Help importing project into node js project #69

velara3 opened this issue Nov 29, 2022 · 2 comments

Comments

@velara3
Copy link

velara3 commented Nov 29, 2022

I'm attempting to import the library into a node js project and I'm getting some errors. I'm working on getting up to speed on all things node js but I am able to use other libraries using requires. I'm also using Typescript.

At the top of module, myclass.ts I have:
import Psd from "@webtoon/psd";

This generates this error:

[Error [ERR_REQUIRE_ESM]: Must use import to load ES Module:
require() of ES modules is not supported.
require() of /Users/project/node_modules/@webtoon/psd/dist/index.js from /Users/project/MyProjectClass.ts 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 index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /Users/project/node_modules/@webtoon/psd/package.json.

It doesn't make sense to me what to do with that information.

@pastelmind
Copy link
Collaborator

Related to #59

This is because we don't provide a CommonJS bundle yet. We're planning to add one soon-ish.

For now, you'll have to use dynamic import().

// Import actual package
const Psd = await import('@webtoon/psd')

@involker
Copy link

When will the commonjs version be released

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants