ReviewOS

stacks/bun-git-hooks

Cannot find module '../src/git-hooks' postinstall

#800
Open moso opened this 8 days ago ·
8 days ago

Describe the bug

When adding bun-git-hooks to an existing project and reinstalling all dependencies with bun install, I get the following error:

bun install
[6.24ms] ".env"
bun install v1.3.7 (ba426210)
  🔍 Resolving... error: Cannot find module '../src/git-hooks' from 'C:\Users\moso\Code\project\node_modules\.bun\bun-git-hooks@0.3.1\node_modules\bun-git-hooks\scripts\postinstall.ts'

Bun v1.3.7 (Windows x64)

error: postinstall script from "bun-git-hooks" exited with 1

This happens even when my .env-file contains SKIP_BUN_GIT_HOOKS=1 bun install and/or SKIP_INSTALL_GIT_HOOKS=1 bun install.

Running bun install again immediately after resolves the issue, and all dependencies are installed and added to bun.lock. But running bun install twice is hardly a viable fix, and is - at most - a workaround.

No other git hooks projects are defined in either .env, .npmrc, or package.json.

git-hooks.config.ts looks as follows:

import type { GitHooksConfig } from 'bun-git-hooks';

const config: GitHooksConfig = {
    'pre-commit': {
        stagedLint: {
            '*': 'eslint --fix',
        },
    },
};

export default config;

It looks like the script is trying to install itself and sourcing the postinstall.ts from its own node_modules-folder. Dependencies having themselves as dependencies? Or is this a Windows pathing issue?

Reproduction

Simply make a new project on Windows. I'm not sure how to add a reproduction example that simulates running in a specific environment without paying for a server to run a Docker container or similar.

System Info

System:
  OS: Windows 11 10.0.26100
  CPU: (16) x64 AMD Ryzen 7 5800X 8-Core Processor
  Memory: 24.79 GB / 63.90 GB
Binaries:
  Node: 24.13.0 - C:\Program Files\nodejs\node.EXE
  npm: 11.8.0 - C:\Program Files\nodejs\npm.CMD
  pnpm: 10.28.2 - C:\Users\moso\AppData\Roaming\npm\pnpm.CMD
  bun: 1.3.7 - C:\Users\moso\.bun\bin\bun.EXE
Browsers:
  Chrome: 144.0.7559.110
  Edge: Chromium (141.0.3537.57)
  Firefox: 147.0.2 - C:\Program Files\Mozilla Firefox\firefox.exe
  Internet Explorer: 11.0.26100.7309
  Waterfox: 6.6.8 - C:\Program Files\Waterfox\waterfox.exe

Used Package Manager

bun

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.

Sign in to comment on this issue.