Skip to content

Commit 4091a4e

Browse files
committed
preinstall script error fix
*fix #3325 Cursor: Why is this a bug? When a user installs gridstack as a dependency (e.g., npm install gridstack), npm automatically executes the library's preinstall, install, and postinstall scripts on the consumer's machine. Because gridstack.js had "preinstall": "npx only-allow yarn" in its package.json, this script runs during the consumer's installation process. This breaks things in two ways: It attempts to download only-allow dynamically via npx over the network. For users with a private registry or restricted network (like the Nexus registry returning a 401 error in the issue description), this completely halts the installation. Even if it could download, it forces the consumer of the library to use yarn for their own app! If they are trying to build an app with npm or pnpm, our preinstall script will throw an error and refuse to let them install our library. Scripts like only-allow are meant to ensure contributors to the gridstack.js codebase use yarn, but binding it to the preinstall hook in a published library inappropriately enforces this on end-users. Suggestion / Fix The only-allow package itself is actually deprecated for exactly these kinds of reasons. The modern and native way to enforce a package manager for repository contributors is using the "packageManager" field in package.json. Node's built-in corepack reads this and will automatically ensure contributors use the correct package manager. Since gridstack.js already includes "packageManager": "yarn@1.22.22..." in its package.json, the only-allow script is completely redundant anyway. I have gone ahead and removed the "preinstall": "npx only-allow yarn" script from the package.json.
1 parent 006ee14 commit 4091a4e

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

doc/CHANGES.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ Change log
141141
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
142142

143143
## 13.0.0-dev (TBD)
144-
* feat: [#701](https://github.com/gridstack/gridstack.js/issues/701) pageBreak printing support for grids !
144+
* feat: [#701](https://github.com/gridstack/gridstack.js/issues/701) major printing support for grids using PrintOptions (pageBreak, hide, orientation, ...)
145+
* fix: [#3325](https://github.com/gridstack/gridstack.js/issues/3325) preinstall script
145146

146147
## 13.0.0 (2026-07-18)
147148
* NEW: react wrapper: re-did to follow the Angular pattern (drag&Drop between grid doesn't destroy content), events, lazyLoad support, fix memory leak, empty content, etc...

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@
4949
"test:e2e:headed": "playwright test --headed",
5050
"lint": "tsc --project tsconfig.build.json --noEmit && eslint src/*.ts angular/projects/lib/src/**/*.ts react/projects/lib/src/**/*.{ts,tsx}",
5151
"reset": "rm -rf dist node_modules",
52-
"prepublishOnly": "yarn build",
53-
"preinstall": "npx only-allow yarn"
52+
"prepublishOnly": "yarn build"
5453
},
5554
"keywords": [
5655
"Typescript",

0 commit comments

Comments
 (0)