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

Fix Node.JS import #7

Closed
d9k opened this issue Dec 5, 2023 · 2 comments
Closed

Fix Node.JS import #7

d9k opened this issue Dec 5, 2023 · 2 comments

Comments

@d9k
Copy link

d9k commented Dec 5, 2023

/home/d9k/.nvm/versions/node/v20.8.0/bin/node --nolazy -r ts-node/register/transpile-only parse-supabase-generated-types-with-babel.ts
Error [ERR_REQUIRE_ESM]: require() of ES Module /home/d9k/cr/pr/examples/ts/supabase-demo/node_modules/.pnpm/json-loose@1.2.2/node_modules/json-loose/dist/index.cjs.js from /home/d9k/cr/pr/examples/ts/supabase-demo/parse-supabase-generated-types-with-babel.ts not supported.
index.cjs.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
Instead either rename index.cjs.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /home/d9k/cr/pr/examples/ts/supabase-demo/node_modules/.pnpm/json-loose@1.2.2/node_modules/json-loose/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).

    at Object.<anonymous> (/home/d9k/cr/pr/examples/ts/supabase-demo/parse-supabase-generated-types-with-babel.ts:33:38)
    at Module._compile (/home/d9k/cr/pr/examples/ts/supabase-demo/node_modules/.pnpm/ts-node@10.9.1_@types+node@20.10.3_typescript@3.9.10/node_modules/ts-node/dist/index.js:857:29)
    at Object..ts (/home/d9k/cr/pr/examples/ts/supabase-demo/node_modules/.pnpm/ts-node@10.9.1_@types+node@20.10.3_typescript@3.9.10/node_modules/ts-node/dist/index.js:859:16) {
  code: 'ERR_REQUIRE_ESM'
}
Process exited with code 1
@d9k
Copy link
Author

d9k commented Dec 5, 2023

Was able to import json-loose with https://github.com/privatenumber/tsx

bent10 added a commit that referenced this issue Dec 10, 2023
github-actions bot pushed a commit that referenced this issue Dec 10, 2023
## [1.2.3](v1.2.2...v1.2.3) (2023-12-10)

### Bug Fixes

* renames `index.cjs.js` to `index.cjs` ([50ae08b](50ae08b)), closes [#7](#7)
@bent10
Copy link
Owner

bent10 commented Dec 10, 2023

I have released v1.2.3 to address this issue. Could you please confirm that it is working well on your end?

@bent10 bent10 closed this as completed Dec 11, 2023
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

2 participants