payload icon indicating copy to clipboard operation
payload copied to clipboard

#6718 generate:types Fails with Endpoint in Collection Configuration reproduction

Open peterkunsay opened this issue 2 years ago • 2 comments

Link to reproduction

https://github.com/peterkunsay/payload-3.0-demo-generate-types-issue/tree/master

Payload Version

3.0.0-beta.45

Node Version

v20.9.0

Next.js Version

15.0.0-rc.0

Describe the Bug

Hello,

As requested by @AlessioGr, I have created a reproduction repository for issue #6718. I have completely stripped down my original project, and the issue persists. When I include any endpoint in my ./src/admin/collections/admin_media.ts file, the generate:types command fails with the following error:

pnpm run generate:types

> [email protected] generate:types D:\Projects\reproduction\new-semi
> payload generate:types

Error resolving path: [Error: ENOENT: no such file or directory, lstat 'D:\Projects\reproduction\new-semi\node_modules\D:\Projects\reproduction\new-semi\node_modules\.pnpm\[email protected][email protected]_react-dom@19_u5g2i42qnvpr6u6rbf5n5egehi\node_modules\next\server.js'] {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'lstat',
  path: 'D:\\Projects\\reproduction\\new-semi\\node_modules\\D:\\Projects\\reproduction\\new-semi\\node_modules\\.pnpm\\[email protected][email protected]_react-dom@19_u5g2i42qnvpr6u6rbf5n5egehi\\node_modules\\next\\server.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 new NodeError (node:internal/errors:406:5)
    at validateString (node:internal/validators:162:11)
    at pathToFileURL (node:url:1024:3)
    at resolve (file:///D:/Projects/reproduction/new-semi/node_modules/.pnpm/[email protected]_@[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:833:22)
    at async Hooks.resolve (node:internal/modules/esm/hooks:278:24)
    at async handleMessage (node:internal/modules/esm/worker:168:18) {
  code: 'ERR_INVALID_ARG_TYPE'
}

Node.js v20.9.0
 ELIFECYCLE  Command failed with exit code 1.

My system specs: image

I hope the reproduction repo is correct and will be helpful. Thank you again for your hard work!

Reproduction Steps

  • Stripped down my original project
  • Did clean install
  • Issue is persistent

Adapters and Plugins

db-mongodb

peterkunsay avatar Jun 15 '24 11:06 peterkunsay

Thank you! This has been fixed in https://github.com/payloadcms/payload/pull/6804 and will be available in the next beta release (today) :)

Also, make sure to remove that require statement you have. This will not work anymore, require is not a thing in esm. You can use await import's instead

AlessioGr avatar Jun 17 '24 14:06 AlessioGr

This issue has been automatically locked. Please open a new issue if this issue persists with any additional detail.

github-actions[bot] avatar Sep 07 '24 01:09 github-actions[bot]