Skip to content

Fail to run simple-git-hooks with npx or npm execΒ #69

@motss

Description

@motss

Issues

Running simple-git-hooks with npx or npm exec causes the installation to fail.

$ npx -y simple-git-hooks@latest

> [email protected] postinstall
> node ./postinstall.js

node:internal/fs/utils:344fy:simple-git-hooks: sill audit bulk request { 'simple-git-hooks': [ '2.7.0' ] }
    throw err;
    ^

Error: ENOENT: no such file or directory, stat '/Users/user/.npm/_npx/318daabbad435bbd/package.json'
    at Object.statSync (node:fs:1536:3)
    at _getPackageJson (/Users/user/.npm/_npx/318daabbad435bbd/node_modules/simple-git-hooks/simple-git-hooks.js:174:13)
    at checkSimpleGitHooksInDependencies (/Users/user/.npm/_npx/318daabbad435bbd/node_modules/simple-git-hooks/simple-git-hooks.js:102:34)
    at postinstall (/Users/user/.npm/_npx/318daabbad435bbd/node_modules/simple-git-hooks/postinstall.js:15:9)
    at Object.<anonymous> (/Users/user/.npm/_npx/318daabbad435bbd/node_modules/simple-git-hooks/postinstall.js:24:1)
    at Module._compile (node:internal/modules/cjs/loader:1097:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1149:10)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
  errno: -2,
  syscall: 'stat',
  code: 'ENOENT',
  path: '/Users/user/.npm/_npx/318daabbad435bbd/package.json'
}

Node.js v17.2.0

Expected behavior

simple-git-hooks should run correctly using npx or npm exec locally.

Actual behavior

Running npx -y simple-git-hooks or npm exec -y -- simple-git-hooks@latest throws error.

Debugging details

$ npx -y envinfo

 System:
    OS: macOS 12.2
    CPU: (10) arm64 Apple M1 Max
    Memory: 13.90 GB / 64.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 17.2.0
    npm: 8.1.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions