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

Error [ERR_REQUIRE_ESM]: require() of ES Module #36

Closed
dinesh-it opened this issue Dec 29, 2022 · 3 comments
Closed

Error [ERR_REQUIRE_ESM]: require() of ES Module #36

dinesh-it opened this issue Dec 29, 2022 · 3 comments

Comments

@dinesh-it
Copy link
Contributor

node version: v18.12.1
wdio version: 8.0.15

I recently upgraded the node and libraries on our CI and getting the following error (when using teamcity reporter):

[0-0] 2022-12-29T10:06:50.764Z ERROR @wdio/local-runner: Failed launching test session: Error: Couldn't initialise "wdio-teamcity-reporter".
[0-0] Error [ERR_REQUIRE_ESM]: require() of ES Module /usr/lib/node_modules/@wdio/reporter/build/index.js from /usr/lib/node_modules/wdio-teamcity-reporter/index.js not supported.
[0-0] Instead change the require of /usr/lib/node_modules/@wdio/reporter/build/index.js in /usr/lib/node_modules/wdio-teamcity-reporter/index.js to a dynamic import() which is available in all CommonJS modules.
[0-0]     at Object.<anonymous> (/usr/lib/node_modules/wdio-teamcity-reporter/index.js:1:22)
[0-0]     at async Promise.all (index 0)
[0-0]     at async safeImport (file:///usr/lib/node_modules/@wdio/local-runner/node_modules/@wdio/utils/build/utils.js:188:21)
[0-0]     at async initialisePlugin (file:///usr/lib/node_modules/@wdio/local-runner/node_modules/@wdio/utils/build/initialisePlugin.js:32:20)
[0-0]     at async BaseReporter._loadReporter (file:///usr/lib/node_modules/@wdio/local-runner/node_modules/@wdio/runner/build/reporter.js:178:30)
[0-0]     at async Promise.all (index 0)
[0-0]     at async BaseReporter.initReporters (file:///usr/lib/node_modules/@wdio/local-runner/node_modules/@wdio/runner/build/reporter.js:23:27)
[0-0]     at async Runner.run (file:///usr/lib/node_modules/@wdio/local-runner/node_modules/@wdio/runner/build/index.js:68:9)
[0-0]     at safeImport (file:///usr/lib/node_modules/@wdio/local-runner/node_modules/@wdio/utils/build/utils.js:210:15)
[0-0]     at async initialisePlugin (file:///usr/lib/node_modules/@wdio/local-runner/node_modules/@wdio/utils/build/initialisePlugin.js:32:20)
[0-0]     at async BaseReporter._loadReporter (file:///usr/lib/node_modules/@wdio/local-runner/node_modules/@wdio/runner/build/reporter.js:178:30)
[0-0]     at async Promise.all (index 0)
[0-0]     at async BaseReporter.initReporters (file:///usr/lib/node_modules/@wdio/local-runner/node_modules/@wdio/runner/build/reporter.js:23:27)
[0-0]     at async Runner.run (file:///usr/lib/node_modules/@wdio/local-runner/node_modules/@wdio/runner/build/index.js:68:9)
[0-0] FAILED

I tried replacing require with import statements and that giving not a module error..
Am I missing any other dependency here?

@christian-bromann
Copy link
Collaborator

This is because @wdio/reporter is listed within dev dependencies while it should actually be a dependency. This way it would correctly require the v7 reporter package and doesn't fail because it tries to require the v8 ESM package.

Two things need to be done:

  • rewrite the package to ESM (optional but needs to be done eventually)
  • move @wdio/reporter to deps list

Any contributions are welcome!

@dinesh-it
Copy link
Contributor Author

I will try to rewrite package to ESM later

@christian-bromann
Copy link
Collaborator

Thanks for the PR.

I will try to rewrite package to ESM later

Let's tackle this as part of #31

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants