Windows only: `generate:types` not working properly
I encounter the following error when running pnpm generate:types on Windows:
> pnpm generate:types
> [email protected] generate:types C:\Users\tobiasiv\Documents\payload-3.0-demo
> payload generate:types
Error resolving path: Error: ENOENT: no such file or directory, lstat 'C:\Users\tobiasiv\Documents\payload-3.0-demo\node_modules\C:\Users\tobiasiv\Documents\payload-3.0-demo\node_modules\.pnpm\[email protected][email protected][email protected]\node_modules\next\link.js'
at async Object.lstat (node:internal/fs/promises:1018:18)
at async resolveOriginalPath (file:///C:/Users/tobiasiv/Documents/payload-3.0-demo/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/payload/dist/bin/loader/resolveOriginalPath.js:19:27)
at async resolve (file:///C:/Users/tobiasiv/Documents/payload-3.0-demo/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/payload/dist/bin/loader/index.js:79:32)
at async nextResolve (node:internal/modules/esm/hooks:866:22)
at async Hooks.resolve (node:internal/modules/esm/hooks:304:24)
at async handleMessage (node:internal/modules/esm/worker:196:18) {
errno: -4058,
code: 'ENOENT',
syscall: 'lstat',
path: 'C:\\Users\\tobiasiv\\Documents\\payload-3.0-demo\\node_modules\\C:\\Users\\tobiasiv\\Documents\\payload-3.0-demo\\node_modules\\.pnpm\\[email protected][email protected][email protected]\\node_modules\\next\\link.js'
}
node:internal/process/promises:289
triggerUncaughtException(err, true /* fromPromise */);
^
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
at pathToFileURL (node:url:1024:3)
at resolve (file:///C:/Users/tobiasiv/Documents/payload-3.0-demo/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/payload/dist/bin/loader/index.js:79:18)
at async nextResolve (node:internal/modules/esm/hooks:866:22)
at async Hooks.resolve (node:internal/modules/esm/hooks:304:24)
at async handleMessage (node:internal/modules/esm/worker:196:18) {
code: 'ERR_INVALID_ARG_TYPE'
}
Node.js v20.13.1
This issue only occurs on Windows. It works fine on Unix-based systems (tested on macOS and Linux Subsystem).
To reproduce the error:
- Clone the payload 3.0 beta repo from here.
- Create a custom component like this
test.tsx:
import Link from 'next/link'
export const Test = () => {
return <Link href="#">Link</Link>
}
- Add the custom component to
payload.config.ts:
admin: {
autoLogin: {
email: '[email protected]',
password: 'test',
prefillOnly: true,
},
components: {
beforeNavLinks: [Test],
},
},
- Run
pnpm generate:types
The error also occurs when importing from next/navigation or next/headers.
Versions:
- Windows 11 23H2 22631.3593
- Node.js v20.13.1
- pnpm 9.1.0
- payload 3.0.0-beta.34 (error also occurs in version 3.0.0-beta.35)
I had this issue as well, though it was when using next/cache items anywhere inside of payload.config. Reported in #201, but falsely closed, as I thought I had resolved the issue.
I recently switched to Linux, where the issues no longer occur, as you have mentioned.
So, I'm just adding on to this, that it's not only next/navigation, or next/headers, perhaps its anything imported from next. I do know that pnpm@8 is recommended, as opposed to 9, but I don't believe that is part of this issue, as I was using pnpm@8 in my issues as well.
Thank you! This has been fixed in https://github.com/payloadcms/payload/pull/6804 and will be available in the next beta release (today) :)
This issue has been automatically locked. Please open a new issue if this issue persists with any additional detail.