question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

nuxi generate on Windows outpus error " ERROR Only URLs with a scheme in: file, data are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'"

See original GitHub issue

Environment

  • Operating System: Windows_NT
  • Node Version: v17.9.0
  • Nuxt Version: 3.0.0-27491748.3186841
  • Package Manager: pnpm@6.32.6
  • Builder: vite
  • User Config: target
  • Runtime Modules: -
  • Build Modules: -

Reproduction

package.json

"scripts": {
    "generate": "nuxi generate",
  },

nuxt.config.ts

export default defineNuxtConfig({
  target: 'static',
})

When do command pnpm generate in terminal, outputs are:

> @ generate C:\Users\kamas\Apps\nuxt3-electron
> nuxi generate

Nuxt CLI v3.0.0-27491748.3186841                                                          19:43:47
i Vite client warmed up in 1273ms                                                         19:43:52
i Client built in 1635ms                                                                  19:43:53
i Building server...                                                                      19:43:53
√ Server built in 510ms                                                                   19:43:53
√ Generated public .output/public                                                   nitro 19:43:53
start Preparing prerenderer...                                                      nitro 19:43:53

 ERROR  Only URLs with a scheme in: file, data are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'

  at new NodeError (node:internal/errors:372:5)
  at throwIfUnsupportedURLScheme (node:internal/modules/esm/resolve:1075:11)
  at defaultResolve (node:internal/modules/esm/resolve:1155:3)
  at ESMLoader.resolve (node:internal/modules/esm/loader:604:30)
  at ESMLoader.getModuleJob (node:internal/modules/esm/loader:318:18)
  at ESMLoader.import (node:internal/modules/esm/loader:404:22)
  at importModuleDynamically (node:internal/modules/esm/translators:106:35)
  at importModuleDynamicallyCallback (node:internal/process/esm_loader:35:14)
  at prerender (/C:/Users/kamas/Apps/nuxt3-electron/node_modules/.pnpm/nitropack@0.2.1/node_modules/nitropack/dist/chunks/prerender.mjs:2142:39)
  at async /C:/Users/kamas/Apps/nuxt3-electron/node_modules/.pnpm/nuxt3@3.0.0-27491748.3186841/node_modules/nuxt3/dist/index.mjs:1221:9

 ELIFECYCLE  Command failed with exit code 1.

Many thanks for any help.

Describe the bug

This bug occurs with even the very latest version of nuxt3 (3.0.0-27491748.3186841).

Additional context

No response

Logs

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:25 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
MuhammadM1998commented, Dec 4, 2022

I get the same error with @nuxtjs/robots on nuxt dev only. nuxt generate works fine

ERROR  [worker reload] [worker init] Only URLs with a scheme in: file, data are supported by the default ESM loader.
On Windows, absolute paths must be valid file:// URLs. Received protocol 'e:'

at new NodeError (node:internal/errors:393:5)
at throwIfUnsupportedURLScheme (node:internal/modules/esm/resolve:986:11)
at defaultResolve (node:internal/modules/esm/resolve:1066:3)
at nextResolve (node:internal/modules/esm/loader:161:28)
at ESMLoader.resolve (node:internal/modules/esm/loader:831:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:413:18)
at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:77:40)
at link (node:internal/modules/esm/module_job:76:36)
1reaction
evanlong0926commented, Dec 2, 2022

当我使用 pnpm add @nuxtjs/robots 之后也会出现一样的问题,remove 之后工作正常

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only file ...
Notice the error message: Only file and data URLs are supported by the default ... On Windows, absolute paths must be valid file://...
Read more >
The generate Property - Nuxt
The generate property. Configure the generation of your universal web application to a static web application. Type: Object. When calling nuxt.generate() ...
Read more >
Module | webpack - JS.ORG
When used, webpack would generate relative URLs for new URL() syntax, i.e., ... The issuer: An absolute path to the file of the...
Read more >
RequireJS API
If there is no explicit config and data-main is not used, then the default baseUrl is the directory that contains the HTML page...
Read more >
next.config.js: Introduction
js module, not a JSON file. It gets used by the Next.js server and build phases, and it's not included in the browser...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found