Without the clientModule configuration (which works on Linux), I get this error:
TypeError: Cannot read properties of null (reading 'replace')
at loadClient (D:\my\project\node_modules\@fastify\vite\mode\development.js:28:70)
at Vite.setup (D:\my\project\node_modules\@fastify\vite\mode\development.js:51:30)
at async Vite.ready (D:\my\project\node_modules\@fastify\vite\index.js:32:55)
at async main (file:///D:/my/project/server.js:28:2)
With that, I get a different error:
(!) Could not auto-determine entry point from rollupOptions or html files and there are no explicit optimizeDeps.include patterns. Skipping dependency pre-bundling.
Error: ENOENT: no such file or directory, mkdir 'D:/D:/my/project/client/.vite/deps_temp_d4cc20c3'
at Object.mkdirSync (node:fs:1396:3)
at runOptimizeDeps (file:///D:/my/project/node_modules/vite/dist/node/chunks/dep-79892de8.js:44657:14)
at Timeout._onTimeout (file:///D:/my/project/node_modules/vite/dist/node/chunks/dep-79892de8.js:44060:46)
Waiting for the debugger to disconnect...
file:///D:/my/project/node_modules/vite/dist/node/chunks/dep-79892de8.js:41096
const err = new Error(`Failed to load url ${url} (resolved id: ${id})${importer ? ` in ${importer}` : ''}. ${msg}`);
^
Error: Failed to load url D:\D:\my\project\client\index.js (resolved id: D:\D:\my\project\client\index.js). Does the file exist?
at loadAndTransform (file:///D:/my/project/node_modules/vite/dist/node/chunks/dep-79892de8.js:41096:21) {
code: 'ERR_LOAD_URL'
}
Notice the double D:\D:\ in the file names in the error message.
Steps to Reproduce
Create a simple project on Windows following instructions in README;
Run npm run dev.
This is actually my server.js The site-info.mjs module is just a simple object:
import Fastify from 'fastify';
import FastifyVite from '@fastify/vite';
import sensible from '@fastify/sensible';
import { renderToString } from 'vue/server-renderer';
import site_info from './svr/site-info.mjs';
export async function main (dev) {
const server = Fastify();
await server.register(sensible);
await server.register(FastifyVite, {
root: import.meta.url,
dev: dev || process.argv.includes('--dev'),
clientModule: 'index.js',
async createRenderFunction ({ createApp }) {
return async () => ({
element: await renderToString(createApp())
});
}
});
server.setErrorHandler((err, req, reply) => {
console.error(err);
reply.send(err);
});
await server.vite.ready();
server.get('/', async (req, reply) => {
reply.html(await reply.render());
});
server.get('/about', (req, reply) => { reply.send(site_info); });
return server;
}
main().then(server => {
server.listen({ port: 3000 });
console.log('Server listening on port 3000');
});
Prerequisites
Fastify version
4.13.0
Plugin version
4.0.0
Node.js version
18.15.0
Operating system
Windows
Operating system version (i.e. 20.04, 11.3, 10)
21H2
Description
Started to use this plugin, created a simple server + client app following the README.
Without the
clientModule
configuration (which works on Linux), I get this error:With that, I get a different error:
Notice the double
D:\D:\
in the file names in the error message.Steps to Reproduce
npm run dev
.This is actually my
server.js
Thesite-info.mjs
module is just a simple object:Expected Behavior
Just as how it works on Linux.