psd
psd copied to clipboard
Help importing project into node js project
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