@lilly_in_the_valley/test-postinstall-script-package
v1.0.6
Published
A minimal package with a postinstall script
Downloads
26
Readme
yarn add @lilly_in_the_valley/test-postinstall-script-package
https://www.npmjs.com/package/@lilly_in_the_valley/test-postinstall-script-package
Experiment 1.
Didn't see echo postinstall is running while installing this package.
AI said postinstall didn’t fire because Yarn Berry (v2+) disables lifecycle scripts by default for security. Asked to doublecheck and it wasn't confirmed.
I found out see here - https://github.com/yarnpkg/berry/issues/5276 that yarn doesn't print to console by default unless script fails.
Tried the setting enableInlineBuilds: true, removed node_modules, ran yarn install but still didn't see anything in coonsole.
Experiment 2.
Changed postinstall script to do touch postinstall_ran.txt. Didn't see the file in project root. AI said: "The new postinstall runs in the package’s own install directory, not in your project root, so the touch command is creating postinstall_ran.txt inside the package after it’s unpacked—not alongside your app code. Look under node_modules/@lilly_in_the_valley/test-postinstall-script-package/postinstall_ran.txt (or in Yarn Berry’s .yarn/unplugged/... folder)."
And it was right, I found this file in the package own install directory.
Experiment 3.
Updated postinstall script with "touch postinstall_ran_10_nov_10_56.txt" Added enableScripts: false Ran yarn add @lilly_in_the_valley/[email protected]
Checked node_modules, file touch postinstall_ran_10_nov_10_56.txt was there! So this setting had no effect.
Maybe it's this bug? https://github.com/yarnpkg/berry/issues/6258
Experiment 4.
Updated postinstall script with "touch postinstall_ran_10_nov_11_11.txt".
Removed node_modules. Removed lock files (package and yarn) Updated package json with version 1.0.5 of this package
Ran yarn install --mode skip-build
I saw the file postinstall_ran_10_nov_11_11.txt!! So skip-build is not working for some reason.
Docs say: skip-build will not run the build scripts at all. Note that this is different from setting enableScripts to false because the latter will disable build scripts, and thus affect the content of the artifacts generated on disk, whereas the former will just disable the build step - but not the scripts themselves, which just won't run.
But it's not a build script, it's a post install script so this mode doesn't have any effect on disabling postinstall scripts?
Maybe because https://yarnpkg.com/features/pnp - pnp plugin wasn't enabled?
Experiment 5
Added to yarn config
nodeLinker: "pnp" enableScripts: false
published a new version of the package - 1.0.6 with postinstall_ran_10_nov_12_23.txt
