Skip to content

postinstall references missing scripts/postinstall.mjs — not included in published tarball #245

@doobidoo

Description

@doobidoo

Bug

package.json declares:

"postinstall": "node scripts/postinstall.mjs"

but scripts/ is not listed in the "files" whitelist, so scripts/postinstall.mjs is excluded from the published npm package. Every npm install of context-mode@1.0.75 (and earlier versions with this layout) fails with:

Error: Cannot find module '.../scripts/postinstall.mjs'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1475:15)
    ...
    code: 'MODULE_NOT_FOUND'

Verification

  • The file exists upstream on main (HTTP 200 on raw.githubusercontent.com/mksglu/context-mode/main/scripts/postinstall.mjs)
  • It is missing from the installed package at .../context-mode/1.0.18/scripts/ (directory does not exist)
  • package.json "files" field contains ["build", "hooks", ...] — no scripts entry

Impact

  • macOS / Linux: cosmetic — the script is essentially a no-op on these platforms (OpenClaw detection message + Windows-only junction fix), so the install still functions.
  • Windows + nvm4w global install: functional regression — the nvm4w directory-junction fix in postinstall.mjs never runs, so the context-mode.cmd shim can fail to resolve the package module path when npm prefix and node prefix are on different paths.

Reproduction

npm install -g context-mode@1.0.75
# → npm error command sh -c node scripts/postinstall.mjs
# → Error: Cannot find module '.../scripts/postinstall.mjs'

Also reproducible via the built-in upgrader:

node cli.bundle.mjs upgrade
# → "Update failed — GitHub pull failed — Cannot find module scripts/postinstall.mjs"

Fix

Add "scripts" to the files array in package.json:

"files": [
  "build",
  "hooks",
  "scripts",
  ...
]

Alternatively, inline the postinstall logic into build/ output if keeping scripts/ out of the tarball is intentional.

Environment

  • context-mode@1.0.75
  • Node.js v25.8.0
  • macOS 25.3.0 (darwin-arm64)
  • Claude Code plugin cache install path

Related

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