Skip to content

Running husky init, getting no such file or directory package.json #1569

Open
@rubin55

Description

I'm using husky globally. It's installed in /usr/lib/node_modules/husky, binary is /usr/bin/husky.

Doing:

cd ~/
husky init

Leads to:

node:fs:563
  return binding.open(
                 ^

Error: ENOENT: no such file or directory, open 'package.json'
    at Object.openSync (node:fs:563:18)
    at Object.readFileSync (node:fs:447:35)
    at file:///usr/lib/node_modules/husky/bin.js:12:8
    at ModuleJob.run (node:internal/modules/esm/module_job:272:25)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:583:26)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:98:5) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: 'package.json'
}

Node.js v23.8.0

Does husky only work in directories that contain a package.json? Can husky not be configured globally and should a user only use it in a .git directory-containing git repository? I can't tell if the above unhandled error is because of user-error or because of a bug.

Activity

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

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions