Skip to content

fix: build dist/ in prepare so installs from git work - #39

Merged
sidorares merged 1 commit into
masterfrom
fix/build-in-prepare
Oct 15, 2026
Merged

sidorares merged 1 commit into
masterfrom
fix/build-in-prepare

Conversation

@sidorares

Copy link
Copy Markdown
Owner

Installing from git gave a package without dist/, so import 'rfb2' failed with ERR_MODULE_NOT_FOUND. npm runs a git dependency's prepare script before packing it, but not prepack, and dist/ was built in prepack.

Change

  • package.json: "prepack": "npm run build" becomes "prepare": "npm run build". npm runs prepare on git installs, on npm install / npm ci in a clone, and before npm pack and npm publish, so prepack isn't needed. Installs from the registry don't run it. files is unchanged (dist, src).
  • Workflows: dropped the explicit npm run build steps in ci.yml, release-please.yml and release.yml. npm ci now builds dist/, and npm pack --dry-run and npm publish build it again before packing, so the extra step was a third build. Biome already ignores dist/, so lint is unaffected when dist/ exists before it runs.
  • README, Development: npm install also builds dist/, and how to install an unreleased branch from git.

Verification

  • npm ci in a clean clone runs prepare and writes dist/. npm run check passes (Biome, tsc, 291 unit tests).
  • npm pack --dry-run runs prepare and lists dist/ (70 files).
  • Install from this branch in an empty directory (npm 11.12.1, Node 26.0.0):
$ npm init -y >/dev/null && npm install github:sidorares/node-rfb2#fix/build-in-prepare
added 1 package, and audited 2 packages in 10s
$ ls node_modules/rfb2
LICENSE  README.md  dist  package.json  src
$ ls node_modules/rfb2/dist | wc -l
70
$ node --input-type=module -e "const m = await import('rfb2'); console.log(typeof m.connect)"
function
$ node -e "console.log(typeof require('rfb2').createConnection)"
function

The same install from #master gives LICENSE README.md package.json src and ERR_MODULE_NOT_FOUND.

Closes #35

npm runs a git dependency's prepare script before packing it, but not
prepack, so `npm install github:sidorares/node-rfb2#<branch>` gave a
package without dist/ and `import 'rfb2'` failed.

Build in prepare instead of prepack. npm also runs prepare on
`npm install` / `npm ci` in a clone and before `npm pack` and
`npm publish`, so the workflows no longer need their own build step.
@sidorares
sidorares merged commit a8bd4b8 into master Oct 15, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Installing from git gives no dist/ (build in prepare)

1 participant