Skip to content
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

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received type number (0) #1316

Closed
Yuuki-Sakura opened this issue Aug 17, 2023 · 5 comments · Fixed by #1317

Comments

@Yuuki-Sakura
Copy link

Description

get error:

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received type number (0)
    at open (node:internal/fs/promises:591:10)
    at Object.readFile (node:internal/fs/promises:1042:20)

https://github.com/okonet/lint-staged/blob/9da877711a7547b9122c6af91683fb2a2f398184/bin/lint-staged.js#L113
fs/promises is not support file descriptor

Steps to reproduce

exec: echo '{"*.*":["eslint --fix"]}' | npx lint-staged -c -

Debug Logs

expand to view
COPY THE DEBUG LOGS HERE

Environment

  • OS: macOS Ventura
  • Node.js: v20.5.1
  • lint-staged: v14.0.0
@iiroj
Copy link
Member

iiroj commented Aug 17, 2023

Please post your debug logs by running lint-staged with the --debug flag.

@iiroj
Copy link
Member

iiroj commented Aug 17, 2023

As you're using -c -, it will try to read the configuration from stdin. What is the input you are passing?

@Yuuki-Sakura
Copy link
Author

@iiroj

 ❯ echo '{"*.*":["eslint --fix"]}' | npx lint-staged --debug -c -
  lint-staged:bin Options parsed from command-line: {
  allowEmpty: false,
  concurrent: true,
  configPath: '-',
  cwd: undefined,
  debug: true,
  diff: undefined,
  diffFilter: undefined,
  maxArgLength: undefined,
  quiet: false,
  relative: false,
  shell: false,
  stash: true,
  verbose: false
} +0ms
  lint-staged:validateOptions Validating options... +0ms
  lint-staged:validateOptions Validated options! +0ms
  lint-staged Unset GIT_LITERAL_PATHSPECS (was `undefined`) +0ms
  lint-staged:runAll Running all linter scripts... +0ms
  lint-staged:runAll Using working directory `/Users/sakura/nestjs-open-telemetry` +0ms
  lint-staged:resolveGitRepo Resolving git repo from `/Users/sakura/nestjs-open-telemetry` +0ms
  lint-staged:resolveGitRepo Unset GIT_DIR (was `undefined`) +0ms
  lint-staged:resolveGitRepo Unset GIT_WORK_TREE (was `undefined`) +0ms
  lint-staged:execGit Running git command [ 'rev-parse', '--show-prefix' ] +0ms
node:internal/errors:496
    ErrorCaptureStackTrace(err);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received type number (0)
    at open (node:internal/fs/promises:591:10)
    at Object.readFile (node:internal/fs/promises:1042:20)
    at file:///Users/sakura/nestjs-open-telemetry/node_modules/.pnpm/lint-staged@14.0.0/node_modules/lint-staged/bin/lint-staged.js:113:31 {
  code: 'ERR_INVALID_ARG_TYPE'
}

Node.js v20.5.1

@iiroj
Copy link
Member

iiroj commented Aug 21, 2023

Thanks for the details! I can confirm it's broken in v14. This feature had no tests and unfortunately I glossed over it. Can you try if the linked PR #1317 fixes it; it does for me locally.

@iiroj
Copy link
Member

iiroj commented Aug 21, 2023

Well, I wrote some integration tests and everything seems good, so I'll release v14.0.1 for this fix. Thanks again for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants