Skip to content

Couldn't write config file during npm init wdio setup (ENOENT: no such file or directory) #14648

@Poreshraut

Description

@Poreshraut

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

"webdriverio": "^9.18.1"

Node.js Version

v22.17.1

Mode

Standalone Mode

Which capabilities are you using?

What happened?

When setting up WebdriverIO using the npm init wdio configuration wizard, the setup fails with the following error:
⚠️ Couldn't write config file: Error: ENOENT: no such file or directory, scandir
'D:\WebdriverIOBug\node_modules\create-wdio\build\config\templates\exampleFiles\pageobjects'

The example files (e.g., test specs and page objects) are incorrectly placed in the node_modules/create-wdio directory instead of the expected project folder (test/specs and test/pageobjects).

What is your expected behavior?

Expected Behavior
The setup wizard should create:
A test/specs/ folder for test files.
A test/pageobjects/ folder for page object files.
A properly configured wdio.conf.js file in the project directory.
Example files should be placed in the correct locations within the test folder.

Actual Behavior:
The test/specs and test/pageobjects folders are not created in the project directory.
Example test files are incorrectly placed in: node_modules/create-wdio/build/config/templates/exampleFiles/mochaJasmine

How to reproduce the bug.

Steps:
Install Node.js
Create a new project folder and initialize npm:
Install WebdriverIO CLI:
Run the WebdriverIO configuration wizard:
Select the options during the setup:
Observe the error message when the wizard attempts to create the configuration files:
⚠️ Couldn't write config file: Error: ENOENT: no such file or directory, scandir
'D:\WebdriverIOBug\node_modules\create-wdio\build\config\templates\exampleFiles\pageobjects'

Relevant log output

PS D:\WebdriverWebApp> npm install webdriverio --save-dev
npm WARN deprecated node-domexception@1.0.0: Use your platform's native DOMException instead

added 245 packages, and audited 246 packages in 40s

55 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
PS D:\WebdriverWebApp> npm i @wdio/cli --save-dev
npm WARN deprecated lodash.isequal@4.5.0: This package is deprecated. Use require('node:util').isDeepStrictEqual instead.

added 164 packages, and audited 410 packages in 33s

95 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
PS D:\WebdriverWebApp> npx wdio config

===============================
🤖 WDIO Configuration Wizard 🧙
===============================

 A project named "webdriverwebapp" was detected at "D:\WebdriverWebApp", correct? Yes
 What type of testing would you like to do? E2E Testing - of Web or Mobile Applications
 Where is your automation backend located? On my local machine
 Which environment you would like to automate? Web - web applications in the browser
 With which browser should we start? Chrome
 Which framework do you want to use? Mocha (https://mochajs.org/)
 Do you want to use Typescript to write tests? No
 Do you want WebdriverIO to autogenerate some test files? Yes
 What should be the location of your spec files? D:\WebdriverWebApp\test\specs\**\*.js
 Do you want to use page objects (https://martinfowler.com/bliki/PageObject.html)? Yes
 Where are your page objects located? D:\WebdriverWebApp\test\pageobjects\**\*.js
 Which reporter do you want to use? spec
 Do you want to add a plugin to your test setup?
 Would you like to include Visual Testing to your setup? For more information see https://webdriver.io/docs/visual-testing! No
 Do you want to add a service to your test setup?
 Do you want me to run `npm install` Yes


Installing packages using npm:
- @wdio/local-runner@latest
- @wdio/mocha-framework@latest
- @wdio/spec-reporter@latest


npm WARN deprecated inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
npm WARN deprecated glob@8.1.0: Glob versions prior to v9 are no longer supported

added 67 packages, and audited 477 packages in 9s

113 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
 Success!

Creating a WebdriverIO config file...
 Success!

Autogenerate test files...
wdio.js config

Initialize WebdriverIO and setup configuration in your current project.

Options:
      --version          Show version number                           [boolean]
      --watch            Run WebdriverIO in watch mode                 [boolean]
  -h, --hostname         automation driver host address                 [string]
  -p, --port             automation driver port                         [number]
      --path             path to WebDriver endpoints (default "/")      [string]
  -u, --user             username if using a cloud service as automation backend
                                                                        [string]
  -k, --key              corresponding access key to the user           [string]
  -l, --logLevel         level of logging verbosity
                  [choices: "trace", "debug", "info", "warn", "error", "silent"]
      --bail             stop test runner after specific amount of tests have fa
                         iled                                           [number]
      --baseUrl          shorten url command calls by setting a base url[string]
  -w, --waitforTimeout   timeout for all waitForXXX commands            [number]
  -s, --updateSnapshots  update DOM, image or test snapshots            [string]
  -f, --framework        defines the framework (Mocha, Jasmine or Cucumber) to r
                         un the specs                                   [string]
  -r, --reporters        reporters to print out the results on stdout    [array]
      --suite            overwrites the specs attribute and runs the defined sui
                         te                                              [array]
      --spec             run only a certain spec file or wildcard - overrides sp
                         ecs piped from stdin                            [array]
      --exclude          exclude certain spec file or wildcard from the test run
                          - overrides exclude piped from stdin           [array]
      --repeat           Repeat specific specs and/or suites N times    [number]
      --mochaOpts        Mocha options
      --jasmineOpts      Jasmine options
      --cucumberOpts     Cucumber options
      --coverage         Enable coverage for browser runner
      --shard            Shard tests and execute only the selected shard. Specif
                         y in the one-based form like `--shard x/y`, where x is
                         the current and y the total shard.
      --yarn             Install packages via Yarn package manager.
                                                      [boolean] [default: false]
  -y, --yes              will fill in all config defaults without prompting
                                                      [boolean] [default: false]
  -t, --npmTag           define NPM tag to use for WebdriverIO related packages
                                                    [string] [default: "latest"]
      --help             Show help                                     [boolean]

Documentation: https://webdriver.io
@wdio/cli (v9.17.1)

Error: ⚠️ Couldn't write config file: Error: ENOENT: no such file or directory, scandir 'D:\WebdriverWebApp\node_modules\create-wdio\build\cconfig\templates\exampleFiles\mochaJasmine'
    at createWDIOConfig (file:///D:/WebdriverWebApp/node_modules/create-wdio/build/config/cli.js:469:11)
    at async runConfigCommand (file:///D:/WebdriverWebApp/node_modules/create-wdio/build/config/cli.js:1476:3)
    at async Object.handler (file:///D:/WebdriverWebApp/node_modules/create-wdio/build/config/cli.js:1624:3)

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