robots icon indicating copy to clipboard operation
robots copied to clipboard

Runtime error on Windows machines for Nuxt 3 (absolute path must be valid)

Open Xyrai opened this issue 2 years ago • 4 comments

Hey there 👋

I am currently experiencing an error on my Windows (11) machine when trying to install the @nuxtjs/robots 3.0.0 package on nuxt 3.6.1.

Error Log

 ERROR  [worker reload] [worker init] Only URLs with a scheme in: file and 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:399:5)
  at throwIfUnsupportedURLScheme (node:internal/modules/esm/resolve:1059:11)
  at defaultResolve (node:internal/modules/esm/resolve:1135:3)
  at nextResolve (node:internal/modules/esm/loader:163:28)
  at ESMLoader.resolve (node:internal/modules/esm/loader:838:30)
  at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
  at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:77:40)
  at link (node:internal/modules/esm/module_job:76:36)

Node version: 18.15.0

List of things I tried out so far without success:

  1. Using the edge version of Nuxt https://github.com/nuxt/framework/issues/4232#issuecomment-1345385724

  2. Creating a robots.config.ts file https://github.com/nuxt-modules/robots/issues/86#issuecomment-1366121300

Here is a repository containing a replica of the error: https://github.com/Xyrai/nuxt-robots-windows-error/tree/main Additional link to Sandbox, this runs fine since it is not build on a Windows container.

Xyrai avatar Jun 27 '23 13:06 Xyrai

Adding a robots.config.ts file to the root of your project now works with Nuxt 3.6.1. Is there any clarification of why adding this file manually fixes the issue, since it is not mentioned in the README.

Xyrai avatar Jun 28 '23 07:06 Xyrai

Can confirm this happening with nuxt 3.6.1. The workaround of using robots.config.ts works.

jrutila avatar Jul 24 '23 05:07 jrutila

Thanks for this workaround - fixes this issue on 3.6.2.

alexnguyennz avatar Aug 11 '23 04:08 alexnguyennz

We've just experienced this exact same issue, and the underlying issue was actually the fact that some of our imports in TypeScript required .js extensions, otherwise the resolver would create paths like C:/foo/bar instead of file://C:/foo/bar.mjs in the .nuxt output.

I hope this can help others that run into this nearly undebuggable issue.

TheDutchCoder avatar Apr 17 '24 20:04 TheDutchCoder