Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

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:'" #4232

Closed
kamaslau opened this issue Apr 10, 2022 · 25 comments · Fixed by unjs/nitro#70
Assignees
Labels
3.x bug Something isn't working nitro 🔨 p3-minor-bug Priority 3: a bug in an edge case that only affects very specific usage

Comments

@kamaslau
Copy link

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

@kamaslau
Copy link
Author

However, the nuxi build command, ditched the target: 'static' item from nuxt.config.ts of course, works just fine.

@danielroe danielroe self-assigned this Apr 11, 2022
@danielroe danielroe added bug Something isn't working nitro 🔨 p3-minor-bug Priority 3: a bug in an edge case that only affects very specific usage and removed nuxt3 pending triage labels Apr 11, 2022
@pi0
Copy link
Member

pi0 commented Apr 11, 2022

Sorry for the regression. It should be resolved with nitropack@0.2.2. You can get the fix using npx nuxi upgrade --force.****

@iannngit
Copy link

heylo~ i've just made a clean nuxt 3 project using npx nuxi init [product-name] command. i'm facing same error about On Windows, absolute paths must be valid file:// URLs.

-= my env =-

- Windows 11
- Node 16.13.0
- npm 8.1.0

i've tried npx nuxi upgrade --force and checked nitropack in node_modules and it's 0.2.2 .

looking forward to a solution.

@kamaslau
Copy link
Author

Sorry for the regression. It should be resolved with nitropack@0.2.2. You can get the fix using npx nuxi upgrade --force.****

after this, the error has changed to:

PS C:\Users\kamas\Apps\nuxt3-app> pnpm generate           

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

Nuxt CLI v3.0.0-27494471.1091d45                                                          20:33:36



 ERROR  [vite]: Rollup failed to resolve import "ufo" from "virtual:C:/Users/kamas/Apps/nuxt3-app/.nuxt/paths.mjs".This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`build.rollupOptions.external`
  This is most likely unintended because it can break your application at runtime.
  If you do want to externalize this module explicitly add it to
  `build.rollupOptions.external`
  at onRollupWarning (node_modules\.pnpm\vite@2.9.1\node_modules\vite\dist\node\chunks\dep-611778e0.js:39103:19)
  at onwarn (node_modules\.pnpm\vite@2.9.1\node_modules\vite\dist\node\chunks\dep-611778e0.js:38919:13)
  at Object.onwarn (node_modules\.pnpm\rollup@2.70.1\node_modules\rollup\dist\shared\rollup.js:23129:13)
  at ModuleLoader.handleResolveId (node_modules\.pnpm\rollup@2.70.1\node_modules\rollup\dist\shared\rollup.js:22419:26)  at node_modules\.pnpm\rollup@2.70.1\node_modules\rollup\dist\shared\rollup.js:22380:26

 ELIFECYCLE  Command failed with exit code 1.

What could I do next?

@euler-king
Copy link

Sorry for the regression. It should be resolved with nitropack@0.2.2. You can get the fix using npx nuxi upgrade --force.****

I excute: npx nuxi upgrade --force
but it do not work。also has the same error

@keen-wang
Copy link

keen-wang commented Apr 11, 2022

Sorry for the regression. It should be resolved with nitropack@0.2.2. You can get the fix using npx nuxi upgrade --force.****

my nuxt version: 3.0.0-27494471.1091d45
npx nuxi upgrade --force Executing the code did not resolve the issue.
What should I do? thx.

`yarn run v1.22.18
$ nuxi generate
Nuxt CLI v3.0.0-27494471.1091d45 22:05:41
i Vite client warmed up in 4528ms 22:05:56
i Client built in 4568ms 22:05:56
i Building server... 22:05:56
√ Server built in 753ms 22:05:57
√ Generated public .output/public nitro 22:05:57
start Preparing prerenderer... nitro 22:05:57

ERROR Only file and data URLs are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:' 22:05:59

at new NodeError (internal/errors.js:322:7)
at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:814:11)
at Loader.resolve (internal/modules/esm/loader.js:89:40)
at Loader.getModuleJob (internal/modules/esm/loader.js:242:28)
at Loader.import (internal/modules/esm/loader.js:177:28)
at importModuleDynamically (internal/modules/esm/translators.js:114:35)
at exports.importModuleDynamicallyCallback (internal/process/esm_loader.js:30:14)
at prerender (/C:/MyDocument/WebWorkspace/nuxt3-app/node_modules/nitropack/dist/chunks/prerender.mjs:2156:39)
at async /C:/MyDocument/WebWorkspace/nuxt3-app/node_modules/nuxt3/dist/index.mjs:1219:9
at async build (/C:/MyDocument/WebWorkspace/nuxt3-app/node_modules/nuxt3/dist/index.mjs:1653:5)

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.`

@iannngit
Copy link

@keen-wang @euler-king @kamaslau the bug has been fixed by Nuxt team in pull 70. try update with npx nuxi upgrade --force

@kamaslau
Copy link
Author

npx nuxi upgrade --force

On macOS it is, but on Windows it remains an error.

@AndrewBogdanovTSS
Copy link

AndrewBogdanovTSS commented Sep 30, 2022

I can confirm that It's still reproducible on Windows, please, reopen

@danielroe
Copy link
Member

@AndrewBogdanovTSS Would you provide a reproduction in that case?

@AndrewBogdanovTSS
Copy link

@danielroe it will be challenging to provide a web available repro link since it's only reproducible on a Windows machine

Copy link
Member

danielroe commented Oct 5, 2022

You are very welcome to provide a minimal github repo that needs to be run on a Windows machine.

@Ahmedelforjani
Copy link

I have the same problem right now i have 3.0.0-rc.12 version and still facing this issue ? any updates ?

@manniL
Copy link
Member

manniL commented Oct 28, 2022

I have the same problem right now i have 3.0.0-rc.12 version and still facing this issue ? any updates ?

Can you provide a reproduction then?

@AndrewBogdanovTSS
Copy link

@manniL in my case it's related to the issue with @nuxtjs/html-validator
nuxt-modules/html-validator#232

@phanmn
Copy link

phanmn commented Nov 7, 2022

Him I have the same problem 3.0.0-rc.13 version on Windows machine

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 'g:'

@AndrewBogdanovTSS
Copy link

@phanmn do you use @nuxtjs/html-validator ?

@OTTIN-T
Copy link

OTTIN-T commented Nov 14, 2022

@phanmn do you use @nuxtjs/html-validator ?

Hi, I had the same problem with the @nuxtjs/html-validator module but also with 'nuxt-security' module. Everything works fine without it.

@Ahmedelforjani
Copy link

@phanmn do you use @nuxtjs/html-validator ?

for me i had the issue with @nuxtjs/i18n package

@sdsoldi
Copy link

sdsoldi commented Nov 22, 2022

Same issue with new docus theme

npx nuxi init docs -t themes/docus
yarn install
yarn dev

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 'c:'

"devDependencies": {
"nuxt": "^3.0.0",
"@nuxt-themes/docus": "0.3.2"
}

  • Windows 10
  • node v18.12.1
  • yarn 1.22.19 and npm 9.1.2

@vcharov
Copy link

vcharov commented Dec 1, 2022

this error is still displayed

"nuxt": "^3.0.0",
"@nuxtjs/html-validator": "^1.2.1",

@evanlong0803
Copy link

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

@MuhammadM1998
Copy link

MuhammadM1998 commented 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)

@ErriourMe
Copy link

ErriourMe commented Dec 10, 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)

The same problem ;(
Without @nuxtjs/robots

@danielroe
Copy link
Member

danielroe commented Dec 10, 2022

You're probably encountering a similar issue to the one here, which has recently been resolved in nitro and will be available in the next release, or on the edge channel.

If anyone is still experiencing an issue similar to this when trying the edge release, please open a new issue with a reproduction rather than commenting here.

@nuxt nuxt locked as resolved and limited conversation to collaborators Dec 10, 2022
@danielroe danielroe added the 3.x label Jan 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
3.x bug Something isn't working nitro 🔨 p3-minor-bug Priority 3: a bug in an edge case that only affects very specific usage
Projects
None yet
Development

Successfully merging a pull request may close this issue.