Skip to content

On Windows, error loading nitro.config.ts #4122

@gulshan

Description

@gulshan

Environment

OS: Windows 11
Node version: v24.14.0
Nitro version: 3.0.260311-beta

import { defineConfig } from "nitro"

export default defineConfig({
  serverDir: './server',
});

Reproduction

Create a new Nitro app using create-nitro-app in Windows. Run task nitro dev or nitro build, there is an error. Happen both with or without vite.

Describe the bug

On windows, the nitro.config.ts cannot be loaded. Details in the log.

Additional context

No response

Logs

*  Executing task: node --run dev 

Error: Failed to load config file `D:/node/proj1/nitro.config.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 'd:'.  Hint install `jiti` for compatibility.
    at file:///D:/node/proj1/node_modules/.pnpm/nitro@3.0.260311-beta/node_modules/nitro/dist/_libs/c12+rc9.mjs:532:11
    at async file:///D:/node/proj1/node_modules/.pnpm/nitro@3.0.260311-beta/node_modules/nitro/dist/_libs/c12+rc9.mjs:531:27
    at async resolveConfig (file:///D:/node/proj1/node_modules/.pnpm/nitro@3.0.260311-beta/node_modules/nitro/dist/_libs/c12+rc9.mjs:530:21)
    at async loadConfig (file:///D:/node/proj1/node_modules/.pnpm/nitro@3.0.260311-beta/node_modules/nitro/dist/_libs/c12+rc9.mjs:354:22)
    at async watchConfig (file:///D:/node/proj1/node_modules/.pnpm/nitro@3.0.260311-beta/node_modules/nitro/dist/_libs/c12+rc9.mjs:574:15)
    at async _loadUserConfig (file:///D:/node/proj1/node_modules/.pnpm/nitro@3.0.260311-beta/node_modules/nitro/dist/_chunks/nitro.mjs:584:23)
    at async loadOptions (file:///D:/node/proj1/node_modules/.pnpm/nitro@3.0.260311-beta/node_modules/nitro/dist/_chunks/nitro.mjs:572:18)
    at async createNitro (file:///D:/node/proj1/node_modules/.pnpm/nitro@3.0.260311-beta/node_modules/nitro/dist/_chunks/nitro.mjs:840:12)
    at async reload (file:///D:/node/proj1/node_modules/.pnpm/nitro@3.0.260311-beta/node_modules/nitro/dist/cli/_chunks/dev.mjs:37:12)
    at async Object.run (file:///D:/node/proj1/node_modules/.pnpm/nitro@3.0.260311-beta/node_modules/nitro/dist/cli/_chunks/dev.mjs:58:3) {
  [cause]: Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: 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 'd:'
      at throwIfUnsupportedURLScheme (node:internal/modules/esm/load:195:11)
      at defaultLoadSync (node:internal/modules/esm/load:142:3)
      at #loadAndMaybeBlockOnLoaderThread (node:internal/modules/esm/loader:796:12)
      at #loadSync (node:internal/modules/esm/loader:816:49)
      at ModuleLoader.load (node:internal/modules/esm/loader:781:26)
      at ModuleLoader.loadAndTranslate (node:internal/modules/esm/loader:526:31)
      at #getOrCreateModuleJobAfterResolve (node:internal/modules/esm/loader:577:36)
      at afterResolve (node:internal/modules/esm/loader:625:52)
      at ModuleLoader.getOrCreateModuleJob (node:internal/modules/esm/loader:631:12)
      at onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:650:32) {
    code: 'ERR_UNSUPPORTED_ESM_URL_SCHEME'
  }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions