web-std / io

Web standard IO APIs implemented for nodejs
92 stars 31 forks source link

'require() of ES not supported Module' in 2.1.0 #20

Open Thegaram opened 3 years ago

Thegaram commented 3 years ago

I have @web-std/fetch as a sub-dependency. Starting yesterday I started having this issue during build. Downgrading to @web-std/fetch@2.0.3 resolves this.

[path]/node_modules/ts-node/dist/index.js:729
            return old(m, filename);
                   ^
Error [ERR_REQUIRE_ESM]: require() of ES Module [path]/node_modules/@ssttevee/multipart-parser/lib/index.js from [path]/node_modules/@web-std/fetch/dist/index.cjs not supported.
Instead change the require of index.js in [path]/node_modules/@web-std/fetch/dist/index.cjs to a dynamic import() which is available in all CommonJS modules.
    at Object.require.extensions.<computed> [as .js] ([path]/node_modules/ts-node/dist/index.js:729:20)
    at Object.<anonymous> ([path]/node_modules/@web-std/fetch/dist/index.cjs:14:25)
    at Object.require.extensions.<computed> [as .js] ([path]/node_modules/ts-node/dist/index.js:729:20)
    at Object.<anonymous> ([path]/node_modules/nft.storage/dist/src/token.cjs:5:1)
    at Object.require.extensions.<computed> [as .js] ([path]/node_modules/ts-node/dist/index.js:729:20)
    at Object.<anonymous> ([path]/node_modules/nft.storage/dist/src/lib.cjs:8:13)
    at Object.require.extensions.<computed> [as .js] ([path]/node_modules/ts-node/dist/index.js:729:20)
    at Object.<anonymous> ([path]/src/services/ipfs.ts:28:23)
    at Module.m._compile ([path]/node_modules/ts-node/dist/index.js:735:29)
    at Object.require.extensions.<computed> [as .ts] ([path]/node_modules/ts-node/dist/index.js:737:16)
...
joeangel commented 3 years ago

same issue here

in node v16

$ node --version
v16.12.0
$ npm --version
8.1.0

in node 14

$ node --version
v14.17.6
$ npm --version
6.14.15
Gozala commented 2 years ago

I am sorry but I don't have enough cycles to do investigations. If you would like to get this resolved I would suggest:

  1. Create a reproducible test case so that it fail in CI https://github.com/web-std/io/blob/main/.github/workflows/fetch.yml in which would make it easier for anyone to fix this.
  2. Better yet provide a pull request with failing test + fix so it can be addressed quickly.