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:
- Throw a clear error message indicating that
@payload-config path alias is required in tsconfig.json
- OR fall back to a default configuration path (e.g., './src/payload.config.ts')
- 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
- Remove
@payload-config path alias from tsconfig.json:
{
"compilerOptions": {
"paths": {
"@/*": ["./src/*"]
// @payload-config path alias removed
}
}
}
- 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
Describe the Bug
When the
@payload-configpath alias is missing from tsconfig.json'scompilerOptions.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 returnsundefinedforconfigPathwhen the path alias is missing, which later causes a path resolution error.Link to file
Current Behavior
@payload-configpath alias is missing,configPathbecomesundefinedundefinedis passed to path operations causing a TypeErrorExpected Behavior
Either:
@payload-configpath alias is required in tsconfig.jsonLink to the code that reproduces this issue
https://github.com/marwinhormiz/config-path-error
Reproduction Steps
@payload-configpath alias from tsconfig.json:{ "compilerOptions": { "paths": { "@/*": ["./src/*"] // @payload-config path alias removed } } }Which area(s) are affected? (Select all that apply)
area: core
Environment Info