The \"path\" argument must be of type string. Received undefined
Closed this issue · 4 comments
ziimakc commented
On server start following error is thrown The \"path\" argument must be of type string. Received undefined
For server like:
await app.register(remixFastifyPlugin, {
build: path.join(__dirname, '../build/index.js'), // resolves fine
mode: isDev ? 'development' : 'production',
});
Error happens in this file: node_modules/@mcansh/remix-fastify/plugin.js
let remixFastify = async (fastify, options = {}) => {
let {build, mode = process.env.NODE_ENV} = options;
(0, import_tiny_invariant.default)(build, "You must provide a build");
console.error(build) // resolves fine to D:\apps\xx\frontend\build\index.js
console.error(typeof build === "string" ) // true
console.error(resolvedBuild) // {}
let resolvedBuild = typeof build === "string" ? require(build) : build; // require(build) resolves to {}
if (!fastify.hasContentTypeParser("*")) {
fastify.addContentTypeParser("*", (_request, payload, done) => {
done(null, payload);
});
}
fastify.register(import_fastify_racing.default, {handleError: true});
let ROOT_DIR = process.cwd();
let PUBLIC_DIR = path.join(ROOT_DIR, "public");
let ASSET_DIR = path.join(ROOT_DIR, resolvedBuild.assetsBuildDirectory); // resolvedBuild.assetsBuildDirectory is undefined - error
mcansh commented
is this in development?
ziimakc commented
is this in development?
yes
qianjiachun commented
same.
I use the example template, then npm run dev
.
I think it may be related to "/" and "\" of windows.
✅ app ready: http://0.0.0.0:3000
Loading environment variables from .env
node:internal/validators:163
throw new ERR_INVALID_ARG_TYPE(name, 'string', value);
^
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received null
at new NodeError (node:internal/errors:399:5)
at validateString (node:internal/validators:163:11)
at resolve (node:path:167:9)
at FSWatcher.<anonymous> (node:internal/watch_mode/files_watcher:94:30)
at FSWatcher.emit (node:events:513:28)
at FSWatcher._handle.onchange (node:internal/fs/watchers:215:12) {
code: 'ERR_INVALID_ARG_TYPE'
}
Node.js v18.15.0