Closed lackneets closed 1 year ago
probably has to do with this issue https://github.com/nuxt/nuxt.js/issues/15492. I had specifically disabled nitro options on windows platforms with the modules because of pathing issues. maybe it's fixed now, i remove d the restrictions on the module so you can test it out, bout other than that I wouldn't have a fix.
Thanks for the information. Following your clue. I found the problem is caused by Nitro:resolvePath
The windows formatted path is got transformed incorrectly by Nitro. I think it's nothing to do with Nuxt itself.
The solution is to manually hack this file by adding file://
before ${plugin}
, like:
${nitro.options.plugins.map(plugin => `import _${hash(plugin)} from 'file://${plugin}';`).join('\n')}
Tested on linux-like OS. It' correct to add file://
on any of absolute path import.
I'll report to Nitro later.
Nitro will generate a script at .nuxt/dev/index.mjs
before server up:
//...
import { toRouteMatcher, createRouter } from 'file://C:/Users/User/works/Web/frontend/node_modules/radix3/dist/index.mjs';
import _ROuXHMtK6R from 'C:/Users/User/works/Web/frontend/.nuxt/nitro-fetch.mjs';
import { createProxyServer } from 'file://C:/Users/User/works/Web/frontend/node_modules/@refactorjs/http-proxy/dist/index.mjs';
//...
Then node complains:
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:'
In brief,
C:/foo/bar.js
should be corrected to:
file://C:/foo/bar.js
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Environment
Nuxt Config
Reproduction
(It's a bug related to platform)
Describe the bug
I run Nuxt at port
3000
while there is a rails api server at3001
. In this case, I setuphttp://localhost:3000/api/*
proxies tohttp://localhost:3001/api/*
.This is both works on a Alpine OS and my MacOS Ventura. However it breaks on my colleague's Windows 10 also mine when api get fetched by SSR. But I can normally access to
http://localhost:3000/api/*
without any error. I've tried other public domain URL, but nothing changes.Furthermore, when
ssr
set tofalse
will prevent this error.For this reason, I'm convinced that is a bug highly related to Window Platform and SSR. Maybe it's caused by Vite or Nitro.
Additional context
I've checked bellow links, but nothing helps:
Logs