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 import fails #12

Open
halovanic opened this issue May 8, 2023 · 0 comments
Open

ESM import fails #12

halovanic opened this issue May 8, 2023 · 0 comments

Comments

@halovanic
Copy link

When I try to use import AzureDevopsService from "@gmangiapelo/wdio-azure-devops-service" in V8 with a plain JavaScript project (no TypeScript or Babel to modify node_modules), it fails on internal imports:

Error: Failed to initilialise launcher service unknown: Error: Couldn't initialise "@gmangiapelo/wdio-azure-devops-service".
C:\dev\e2e\node_modules\@gmangiapelo\wdio-azure-devops-service\dist\esm\index.js:1
import AzureDevopsService from './azure-devops-service';

One way I was able to resolve this was:

  1. Change the type of both of your modules to "module" in package.json
  2. Update all file imports to use a full .js path reference as Node's module system is not as forgiving as Babel or TypeScript's.

A simpler way seems to be to simply set your import reference in wdio-azure-devops-service's package.json to also point to the cjs version as with require. This seems to work correctly in an import scenario without having to alter anything further.

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

1 participant