Skip to content

[🐛 Bug]: First time test run of WDIO with default configs results in ES related errors #10901

@zac11

Description

@zac11

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

latest

Node.js Version

v20.5.0

Mode

Standalone Mode

Which capabilities are you using?

capabilities: [{
        browserName: 'chrome'
    }],

What happened?

I started with WDIO installation following these steps

  • Created a git repo, cloned it on my system and did npm init
  • Proceeded with npm init wdio and accepted the default behavior in most cases
  • Ran npm run wdio and faced errors

Attached screenshot of the npm init wdio step

Screenshot 2023-08-09 at 11 10 26 AM

What is your expected behavior?

The initial npm run wdio should have worked fine. Instead it started throwing error -

SyntaxError: Cannot use import statement outside a module

Full stack trace I have pasted in the log output section.

How to reproduce the bug.

Relevant log output

npm run wdio

> wdio-work-demo@1.0.0 wdio
> wdio run ./wdio.conf.ts

2023-08-09T05:30:14.234Z ERROR @wdio/config:ConfigParser: Failed loading configuration file: file:///Users/annubha/Documents/Rahul/wdio-work-demo/wdio.conf.ts: Cannot use import statement outside a module
/Users/annubha/Documents/Rahul/wdio-work-demo/wdio.conf.ts:1
import type { Options } from '@wdio/types'
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at internalCompileFunction (node:internal/vm:73:18)
    at wrapSafe (node:internal/modules/cjs/loader:1153:20)
    at Module._compile (node:internal/modules/cjs/loader:1197:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1287:10)
    at Module.load (node:internal/modules/cjs/loader:1091:32)
    at Module._load (node:internal/modules/cjs/loader:938:12)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:165:29)
    at ModuleJob.run (node:internal/modules/esm/module_job:192:25)
    at async CustomizedModuleLoader.import (node:internal/modules/esm/loader:228:24)
    at async ConfigParser.addConfigFile (file:///Users/annubha/Documents/Rahul/wdio-work-demo/node_modules/@wdio/config/build/lib/ConfigParser.js:85:36)
    at async ConfigParser.initialize (file:///Users/annubha/Documents/Rahul/wdio-work-demo/node_modules/@wdio/config/build/lib/ConfigParser.js:47:13)
    at async Launcher.run (file:///Users/annubha/Documents/Rahul/wdio-work-demo/node_modules/@wdio/cli/build/launcher.js:37:9)

Code of Conduct

  • I agree to follow this project's Code of Conduct

Is there an existing issue for this?

  • I have searched the existing issues

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions