Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

require() of ES modules is not supported. #362

Closed
ivanzwb opened this issue Sep 5, 2022 · 3 comments
Closed

require() of ES modules is not supported. #362

ivanzwb opened this issue Sep 5, 2022 · 3 comments

Comments

@ivanzwb
Copy link

ivanzwb commented Sep 5, 2022

When import zip.js in Typescript project.

import { ZipReader, ZipWriter } from '@zip.js/zip.js';

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: \node_modules@zip.js\zip.js\index.js
require() of ES modules is not supported.

Can we support the commonjs module as well?

@gildas-lormeau
Copy link
Owner

gildas-lormeau commented Sep 5, 2022

Add "type": "module" in your package.json file. zip.js was not designed for Node.js. It just turned out that as time passed, Node.js became more and more compatible with zip.js. That is why it does not offer CommonJS support.

@peaceps
Copy link

peaceps commented Sep 7, 2022

When import zip.js in Typescript project.

import { ZipReader, ZipWriter } from '@zip.js/zip.js';

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: [node_modules@zip.js](mailto:node_modules@zip.js)\zip.js\index.js require() of ES modules is not supported.

Can we support the commonjs module as well?

We can use tsimportlib to do async import for commonjs

@gildas-lormeau
Copy link
Owner

I'm moving this issue to the Discussions tab because CommonJS support in zip.js is not planned but we can discuss it if needed.

Repository owner locked and limited conversation to collaborators Sep 9, 2022
@gildas-lormeau gildas-lormeau converted this issue into discussion #365 Sep 9, 2022
gildas-lormeau added a commit that referenced this issue Sep 19, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
None yet
Development

No branches or pull requests

3 participants