Skip to content

TypeError when @payload-config path alias is missing from tsconfig.json #9796

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
marwinhormiz opened this issue Dec 6, 2024 · 2 comments · May be fixed by #9798
Closed

TypeError when @payload-config path alias is missing from tsconfig.json #9796

marwinhormiz opened this issue Dec 6, 2024 · 2 comments · May be fixed by #9798

Comments

@marwinhormiz
Copy link
Contributor

Describe the Bug

When the @payload-config path alias is missing from tsconfig.json's compilerOptions.paths, the package fails with a cryptic error:

node:path:1464
validateString(path, 'path');
^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
at Object.extname (node:path:1464:5)
at findConfig (/home/marwinhormiz/Documents/bygglov/node_modules/.pnpm/payload@3.4.0_graphql@16.9.0_monaco-editor@0.52.0_react-dom@19.0.0-rc-66855b96-20241106_react_re2uwt7p7ymmoimatcnocwcioe/node_modules/payload/src/config/find.ts:70:12)
at bin (/home/marwinhormiz/Documents/bygglov/node_modules/.pnpm/payload@3.4.0_graphql@16.9.0_monaco-editor@0.52.0_react-dom@19.0.0-rc-66855b96-20241106_react_re2uwt7p7ymmoimatcnocwcioe/node_modules/payload/dist/bin/index.js:46:24)
at start (file:///home/marwinhormiz/Documents/bygglov/node_modules/.pnpm/payload@3.4.0_graphql@16.9.0_monaco-editor@0.52.0_react-dom@19.0.0-rc-66855b96-20241106_react_re2uwt7p7ymmoimatcnocwcioe/node_modules/payload/bin.js:30:13) {
code: 'ERR_INVALID_ARG_TYPE'
}

This happens because the code in getTSConfigPaths() silently returns undefined for configPath when the path alias is missing, which later causes a path resolution error.

Link to file

Current Behavior

  • If @payload-config path alias is missing, configPath becomes undefined
  • This undefined is passed to path operations causing a TypeError
  • The error message doesn't indicate the root cause (missing path alias)

Expected Behavior

Either:

  1. Throw a clear error message indicating that @payload-config path alias is required in tsconfig.json
  2. OR fall back to a default configuration path (e.g., './src/payload.config.ts')
  3. OR allow configuration via environment variables as an alternative

Link to the code that reproduces this issue

https://github.com/marwinhormiz/config-path-error

Reproduction Steps

  1. Remove @payload-config path alias from tsconfig.json:
{
  "compilerOptions": {
    "paths": {
      "@/*": ["./src/*"]
      // @payload-config path alias removed
    }
  }
}
  1. Run any payload command such as generate:types or generate:importmap

Which area(s) are affected? (Select all that apply)

area: core

Environment Info

Node.js v20.18.1

Binaries:
  Node: 20.18.1
  npm: 10.8.2
  pnpm: 9.14.4
Relevant Packages:
  payload: 3.4.0
Operating System:
  Platform: linux
  Arch: x64
@marwinhormiz marwinhormiz added status: needs-triage Possible bug which hasn't been reproduced yet validate-reproduction Auto-added tag on create to tell bot to check recreation URL, removed after check. labels Dec 6, 2024
@github-actions github-actions bot added created-by: Contributor and removed validate-reproduction Auto-added tag on create to tell bot to check recreation URL, removed after check. labels Dec 6, 2024
@jessrynkar
Copy link
Member

Hi @marwinhormiz thanks for raising this and apologies for our delayed response!

I no longer see this behavior on the latest version v3.37.0 - it also appears that the reproduction you linked no longer exists.

I'm going to close this issue as it is several versions old now and I am unable to reproduce - if you still experience this behavior on v3.37.0 please feel free to open a new issue!

@github-actions github-actions bot removed the status: needs-triage Possible bug which hasn't been reproduced yet label May 8, 2025
Copy link
Contributor

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

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants