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

ESM not-supported error on v3 #9

Closed
Kolahzary opened this issue Jun 16, 2023 · 2 comments
Closed

ESM not-supported error on v3 #9

Kolahzary opened this issue Jun 16, 2023 · 2 comments

Comments

@Kolahzary
Copy link

Kolahzary commented Jun 16, 2023

I'm trying to use turkey-neighbourhoods@v3 in a nx monorepo with the default tsconfig

> nx run my-app-name:serve:development

node:internal/errors:490
    ErrorCaptureStackTrace(err);
    ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /path-to-repo/node_modules/.pnpm/[email protected]/node_modules/turkey-neighbourhoods/dist/turkey-neighbourhoods.cjs.js not supported.
turkey-neighbourhoods.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 rename turkey-neighbourhoods.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 /path-to-repo/node_modules/.pnpm/[email protected]/node_modules/turkey-neighbourhoods/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).

    at Module._load (/path-to-repo/node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected]/node_modules/@nx/js/src/executors/node/node-with-require-overrides.js:18:31)
    at Object.defineProperty.value (/path-to-repo/dist/apps/my-app-name/main.js:6252:18)
    at __webpack_require__ (/path-to-repo/dist/apps/my-app-name/main.js:6448:41)
    at Array.<anonymous> (/path-to-repo/dist/apps/my-app-name/main.js:6211:33)
    at __webpack_require__ (/path-to-repo/dist/apps/my-app-name/main.js:6448:41)
    at Object.defineProperty.value (/path-to-repo/dist/apps/my-app-name/main.js:5734:28)
    at __webpack_require__ (/path-to-repo/dist/apps/my-app-name/main.js:6448:41)
    at Object.defineProperty.value (/path-to-repo/dist/apps/my-app-name/main.js:5408:48)
    at __webpack_require__ (/path-to-repo/dist/apps/my-app-name/main.js:6448:41)
    at Object.defineProperty.value (/path-to-repo/dist/apps/my-app-name/main.js:5390:22)
    at __webpack_require__ (/path-to-repo/dist/apps/my-app-name/main.js:6448:41)
    at Object.defineProperty.value (/path-to-repo/dist/apps/my-app-name/main.js:3796:30)
    at __webpack_require__ (/path-to-repo/dist/apps/my-app-name/main.js:6448:41)
    at Object.defineProperty.value (/path-to-repo/dist/apps/my-app-name/main.js:3719:28)
    at __webpack_require__ (/path-to-repo/dist/apps/my-app-name/main.js:6448:41)
    at Object.defineProperty.value (/path-to-repo/dist/apps/my-app-name/main.js:1530:31)
    at __webpack_require__ (/path-to-repo/dist/apps/my-app-name/main.js:6448:41)
    at Object.defineProperty.value (/path-to-repo/dist/apps/my-app-name/main.js:1513:22)
    at __webpack_require__ (/path-to-repo/dist/apps/my-app-name/main.js:6448:41)
    at Object.defineProperty.value (/path-to-repo/dist/apps/my-app-name/main.js:412:20)
    at __webpack_require__ (/path-to-repo/dist/apps/my-app-name/main.js:6448:41)
    at Array.<anonymous> (/path-to-repo/dist/apps/my-app-name/main.js:14:22)
    at __webpack_require__ (/path-to-repo/dist/apps/my-app-name/main.js:6448:41)
    at /path-to-repo/dist/apps/my-app-name/main.js:6475:37
    at Object.<anonymous> (/path-to-repo/dist/apps/my-app-name/main.js:6480:12)
    at Module._load (/path-to-repo/node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected]/node_modules/@nx/js/src/executors/node/node-with-require-overrides.js:10:31) {
  code: 'ERR_REQUIRE_ESM'
}

Node.js v18.15.0

@muratgozel
Copy link
Owner

Hey @Kolahzary I have updated the library to fix this error. Could you check if everything is okay please?

@Kolahzary
Copy link
Author

Thanks for your commit @muratgozel,
It's fixed and works perfectly, this issue can be closed

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