webtoon / psd

Fast zero-dependency PSD parser for the web and Node.js

Home Page:https://webtoon.github.io/psd

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Help importing project into node js project

velara3 opened this issue · comments

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.

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')

When will the commonjs version be released