From e0acc33a2055862340d80f3ed6aefd2cc6bdd491 Mon Sep 17 00:00:00 2001 From: Josh Mandel Date: Fri, 4 Dec 2026 09:27:03 -0600 Subject: [PATCH] npm 12 global install: allow the native modules' install scripts npm 12 doesn't run the install scripts of dependencies unless they are allowed, and for npm install -g it doesn't read the allowScripts in the installed package's package.json. sqlite3, better-sqlite3 and roaring are then left without their binary. The README install command and the published install check now pass --allow-scripts. Co-Authored-By: Claude --- .github/workflows/published-install-check.yml | 8 +++++-- CHANGELOG.md | 3 ++- README.md | 21 +++++++++++++++++-- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/.github/workflows/published-install-check.yml b/.github/workflows/published-install-check.yml index f9c3f9ff..cb64ddf5 100644 --- a/.github/workflows/published-install-check.yml +++ b/.github/workflows/published-install-check.yml @@ -60,11 +60,15 @@ jobs: echo "packed $tgz" # a global install, into its own prefix so it needs no sudo: the same layout as - # /usr/lib/node_modules/fhirsmith. The dependencies come from the registry, as for npm install -g fhirsmith + # /usr/lib/node_modules/fhirsmith. The dependencies come from the registry, as for npm install -g fhirsmith. + # --allow-scripts is the install command in the README: npm 12 doesn't run the install scripts of + # dependencies unless they are allowed, and for a global install only the command line or the user's + # npm config can allow them (the allowScripts in our package.json isn't read). Without it sqlite3, + # better-sqlite3 and roaring are left without their binary. Keep the list the same as in the README - name: Install the package globally run: | prefix="$RUNNER_TEMP/global" - npm install -g --prefix "$prefix" "$TGZ" + npm install -g --prefix "$prefix" --allow-scripts=bcrypt,better-sqlite3,koffi,roaring,sqlite3 "$TGZ" echo "PKG_DIR=$(npm root -g --prefix "$prefix")/fhirsmith" >> "$GITHUB_ENV" - name: Check the installed package diff --git a/CHANGELOG.md b/CHANGELOG.md index b85284db..815f9fb9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,7 +21,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed -- +- The 1.1.0 npm package didn't include `ips/vendor/` (the IPS export libraries the server loads at startup): `.npmignore` had an unanchored `vendor/` +- `npm install -g fhirsmith` with npm 12 leaves sqlite3, better-sqlite3 and roaring without their native binary (any FHIRsmith version; roaring is a dependency since 1.1.0): npm 12 doesn't run the install scripts of dependencies unless they are allowed, and for a global install it doesn't read the `allowScripts` in our package.json. The install command in the README is now `npm install -g --allow-scripts=bcrypt,better-sqlite3,koffi,roaring,sqlite3 fhirsmith`, and the published install check installs that way ### Removed diff --git a/README.md b/README.md index 67983296..393db30f 100644 --- a/README.md +++ b/README.md @@ -174,8 +174,8 @@ use the `FHIRSMITH_DATA_DIR` environment variable to locate the data directory. ### npm Global Install ```bash -# Install globally -npm install -g fhirsmith +# Install globally, allowing the native modules' install scripts (see below) +npm install -g --allow-scripts=bcrypt,better-sqlite3,koffi,roaring,sqlite3 fhirsmith # Create a data directory mkdir -p /var/lib/fhirsmith @@ -197,6 +197,23 @@ FHIRSMITH_DATA_DIR=/var/lib/fhirsmith fhirsmith For cluster mode (a master and tx-workers - see [cluster.md](cluster.md)), run `fhirsmith-cluster` instead of `fhirsmith`. +#### Why `--allow-scripts` + +Three of FHIRsmith's dependencies (sqlite3, better-sqlite3 and roaring) get their native binary +from an install script. npm 12 doesn't run the install scripts of dependencies unless they are +allowed, and for a global install it only takes that from the command line or your npm config. +A plain `npm install -g fhirsmith` with npm 12 finishes without an error (npm lists the blocked +scripts in a warning), and the server then stops at startup with "Could not locate the bindings +file" or "Cannot find module './build/Release/roaring.node'". npm 11 runs the scripts either way. + +Instead of the option, the scripts can be allowed once for all global installs by this user: + +```bash +npm config set allow-scripts=bcrypt,better-sqlite3,koffi,roaring,sqlite3 --location=user +``` + +To repair an install made without it, install again with the option. + ### Changing the Node.js version Some of FHIRsmith's dependencies (the SQLite drivers) are native modules, built for the