You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CodeceptJS fails to load config file on Windows (tried in powershell and git bash):
$ pnpm codeceptjs run
Error: Failed to load config file C:\test\e2e\codecept.conf.js:
Only URLs with a scheme in: file, data, and node are supported by the default ESM loader.
On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'
at loadConfigFile (file:///C:/test/e2e/node_modules/.pnpm/codeceptjs@4.0.2_@types+node@25.9.0/node_modules/codeceptjs/lib/config.js:272:15)
at async Config.load (file:///C:/test/e2e/node_modules/.pnpm/codeceptjs@4.0.2_@types+node@25.9.0/node_modules/codeceptjs/lib/config.js:124:16)
at async getConfig (file:///C:/test/e2e/node_modules/.pnpm/codeceptjs@4.0.2_@types+node@25.9.0/node_modules/codeceptjs/lib/command/utils.js:16:12)
at async default (file:///C:/test/ui/e2e/node_modules/.pnpm/codeceptjs@4.0.2_@types+node@25.9.0/node_modules/codeceptjs/lib/command/run.js:19:16)
at async Command.<anonymous> (file:///C:/test/e2e/node_modules/.pnpm/codeceptjs@4.0.2_@types+node@25.9.0/node_modules/codeceptjs/bin/codecept.js:40:7)
passing a file URL fails as well:
$ pnpm codeceptjs run -c "file:///C:/test/e2e/codecept.config.js"
Error: Config file C:\test\e2e\file:\C:\test\e2e\codecept.config.js does not exist. Execute 'codeceptjs init' to create config
Error: Could not load plugin from 'C:\test\e2e\plugins\plugin.ts': Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'
at loadPluginAsync (file:///C:/test/e2e/node_modules/.pnpm/codeceptjs@4.0.2_@types+node@25.6.2/node_modules/codeceptjs/lib/container.js:688:11)
at async createPlugins (file:///C:/test/e2e/node_modules/.pnpm/codeceptjs@4.0.2_@types+node@25.6.2/node_modules/codeceptjs/lib/container.js:755:29)
at async Container.create (file:///C:/test/e2e/node_modules/.pnpm/codeceptjs@4.0.2_@types+node@25.6.2/node_modules/codeceptjs/lib/container.js:81:25)
at async Codecept.init (file:///C:/test/e2e/node_modules/.pnpm/codeceptjs@4.0.2_@types+node@25.6.2/node_modules/codeceptjs/lib/codecept.js:105:5)
@kobenguyent I just applied the entire patch (yesterday just the bits for lib/config.js), and it already fails in bin/codecept.js in "dynamicImport", where the absolute path check is missing, causing to resolve relative internal paths against cwd.
May I suggest to move the full check with "isWindows" and "isAbsolutePath" into an own util function and call it everywhere? It would not hurt but would increase safety if code places always expecting abolute paths would check them as well.
@danielrentz Indeed, thanks for the suggestion. I'm thinking the same cause in the beginning just thought there are one or two places needed for those patches but turned out more. Utils is definitely a great approach though. 👍🏻
Really appreciated if you could test this out #5595
Activity
danielrentz commentedon May 29, 2026
Same happens when loading plugins:
Error: Could not load plugin from 'C:\test\e2e\plugins\plugin.ts': Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:' at loadPluginAsync (file:///C:/test/e2e/node_modules/.pnpm/codeceptjs@4.0.2_@types+node@25.6.2/node_modules/codeceptjs/lib/container.js:688:11) at async createPlugins (file:///C:/test/e2e/node_modules/.pnpm/codeceptjs@4.0.2_@types+node@25.6.2/node_modules/codeceptjs/lib/container.js:755:29) at async Container.create (file:///C:/test/e2e/node_modules/.pnpm/codeceptjs@4.0.2_@types+node@25.6.2/node_modules/codeceptjs/lib/container.js:81:25) at async Codecept.init (file:///C:/test/e2e/node_modules/.pnpm/codeceptjs@4.0.2_@types+node@25.6.2/node_modules/codeceptjs/lib/codecept.js:105:5)kobenguyent commentedon Jun 3, 2026
@danielrentz may you help check if #5595 resolves the windows issues?
danielrentz commentedon Jun 3, 2026
@kobenguyent No it still crashes in line 262 of lib/config.js when loading
codecept.config.jskobenguyent commentedon Jun 3, 2026
@danielrentz thanks for testing. Maybe we have luck with this d735b33
danielrentz commentedon Jun 4, 2026
@kobenguyent I just applied the entire patch (yesterday just the bits for lib/config.js), and it already fails in bin/codecept.js in "dynamicImport", where the absolute path check is missing, causing to resolve relative internal paths against cwd.
May I suggest to move the full check with "isWindows" and "isAbsolutePath" into an own util function and call it everywhere? It would not hurt but would increase safety if code places always expecting abolute paths would check them as well.
danielrentz commentedon Jun 4, 2026
I found more places missing the "isAbsolute" path check:
lib/container.js(line 707)lib/codecept.js(line 140)After fixing these three places locally, the tests run again.
Strong argument for the util function, right? :)
kobenguyent commentedon Jun 4, 2026
@danielrentz Indeed, thanks for the suggestion. I'm thinking the same cause in the beginning just thought there are one or two places needed for those patches but turned out more. Utils is definitely a great approach though. 👍🏻
Really appreciated if you could test this out #5595
danielrentz commentedon Jun 4, 2026
@kobenguyent It works!
Two remarks:
import path from 'path'(line35) is now unused.path.isAbsolute('../data/dummy_page.js')is alwaysfalse.kobenguyent commentedon Jun 8, 2026
supposed to be fixed by https://github.com/codeceptjs/CodeceptJS/releases/tag/4.0.4. Closing for now. Don't hesitate to report back if something still broken. Thanks!