{"id":21969589,"url":"https://github.com/cinderblock/test-npm-yarn-lifecycle-scripts","last_synced_at":"2026-04-09T20:02:42.649Z","repository":{"id":143531487,"uuid":"580981687","full_name":"cinderblock/test-npm-yarn-lifecycle-scripts","owner":"cinderblock","description":"Repo for exploring what happens with Yarn/Npm Lifecycle Scripts","archived":false,"fork":false,"pushed_at":"2022-12-23T00:48:28.000Z","size":28,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-28T02:16:05.212Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cinderblock.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-22T00:33:18.000Z","updated_at":"2022-12-22T00:38:18.000Z","dependencies_parsed_at":"2023-03-27T14:27:56.388Z","dependency_job_id":null,"html_url":"https://github.com/cinderblock/test-npm-yarn-lifecycle-scripts","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cinderblock%2Ftest-npm-yarn-lifecycle-scripts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cinderblock%2Ftest-npm-yarn-lifecycle-scripts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cinderblock%2Ftest-npm-yarn-lifecycle-scripts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cinderblock%2Ftest-npm-yarn-lifecycle-scripts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cinderblock","download_url":"https://codeload.github.com/cinderblock/test-npm-yarn-lifecycle-scripts/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245027792,"owners_count":20549388,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-29T14:22:41.239Z","updated_at":"2026-04-09T20:02:42.592Z","avatar_url":"https://github.com/cinderblock.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Test Lifecycle Scripts with Npm, Yarn, et al.\n\nSimple repo to test which lifecycle scripts are run when using `npm`, `yarn`, and `pnpm` to install/setup this package in various ways.\n\n## Test method\n\n1. Setup `package.json` with lifecycle scripts to be shared between package manager\n   - `prepare`\n   - `prepublish`\n   - `prepublishOnly`\n   - `prepack`\n   - `postpack`\n   - `dependencies`\n   - `postinstall`\n1. Run [various standard package manager commands](.github/workflows/test.yml) via [GitHub Actions](https://github.com/cinderblock/test-npm-yarn-lifecycle-scripts/actions)\n   - `npm install`\n   - `npm install \u003curl\u003e`\n   - `npm pack`\n   - `yarn install`\n   - `yarn add \u003curl\u003e`\n   - `yarn pack`\n   - `pnpm install`\n   - `pnpm add \u003curl\u003e`\n   - `pnpm pack`\n1. Manually inspect logs to see which scripts were run and how\n   - Open `output.txt`, where possible, to see which lines were added to the file\n   - Open output of main command and see if \"Ran script:\" message appears\n   - Check `/node_modules/package-prepare` to see which files were included with package (did `.npmignore` work?)\n1. Record results in table below\n\n## Results\n\n_Which lifecycle scripts were run? Which files were included in the package?_\n\n| Package Manager | `.npmignore`           | Add as Dependency                                                                                                                   | Initial Setup                              | Pack                                                                     |\n| --------------- | ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ | ------------------------------------------------------------------------ |\n| npm             | ✅ _(4)_               | ✖️postinstall\u003cbr\u003e_⏭️(in `~/.npm/_cacache`)_\u003cbr\u003e✖️prepublish\u003cbr\u003e✖️prepare\u003cbr\u003e✖️prepare\u003cbr\u003e✖️postinstall\u003cbr\u003e_⏭️(in `./node_modules`)_ | 👀postinstall\u003cbr\u003e👀prepublish\u003cbr\u003e👀prepare | 👀prepack\u003cbr\u003e✖️prepare\u003cbr\u003e👀postpack                                     |\n| pnpm            | ❌ _(12)_              | ✖️postinstall\u003cbr\u003e_⏭️(in `/tmp`)_\u003cbr\u003e✖️prepublish\u003cbr\u003e✖️prepare\u003cbr\u003e👀postinstall\u003cbr\u003e_⏭️(in `./node_modules`)_                         | 👀postinstall\u003cbr\u003e👀prepare                 | 👀prepublish\u003cbr\u003e👀prepare\u003cbr\u003e👀prepublishOnly\u003cbr\u003e👀prepack\u003cbr\u003e👀postpack |\n| yarn            | ✅ _(4)_               | 👀postinstall\u003cbr\u003e_⏭️(in `~/.cache/yarn`)_\u003cbr\u003e👀prepare\u003cbr\u003e✖️postinstall\u003cbr\u003e_⏭️(in `./node_modules`)_                                | 👀postinstall\u003cbr\u003e👀prepublish\u003cbr\u003e👀prepare | 👀prepack\u003cbr\u003e👀postpack                                                  |\n| yarn PnP        | ❓\u003cbr\u003e_(`nodeLinker`)_ | _Inferred, no `output.txt`._\u003cbr\u003e👀postinstall\u003cbr\u003e👀prepare                                                                          | _Not tested_                               | _Not tested_                                                             |\n| yarn 2          | ✅\u003cbr\u003e_(`nodeLinker`)_ | ✖️postinstall\u003cbr\u003e_⏭️(in `/tmp`)_\u003cbr\u003e👀prepack\u003cbr\u003e👀postpack\u003cbr\u003e✖️postinstall\u003cbr\u003e_⏭️(in `./node_modules`)_                           | _Not tested_                               | _Not tested_                                                             |\n| yarn 3          | ✅\u003cbr\u003e_(`nodeLinker`)_ | ✖️postinstall\u003cbr\u003e_⏭️(in `/tmp`)_\u003cbr\u003e👀prepack\u003cbr\u003e👀postpack\u003cbr\u003e✖️postinstall\u003cbr\u003e_⏭️(in `./node_modules`)_                           | _Not tested_                               | _Not tested_                                                             |\n\n_👀/✖️ indicates associated logs were printed to terminal_\n\n### Questions\n\n1. Why does `npm install \u003curl\u003e` run the `prepare` script twice?\n1. Why does `yarn install \u003curl\u003e` run the `postinstall` script twice but only outputs once?\n1. Why does `npm pack` run both scripts, but the `prepare` script's output is never printed?\n1. Why doesn't `pnpm` respect `.npmignore`\u0026`package.json#files` field?\n1. Why is `pnpm` a different order than `npm`?\n1. How is a package installed with \"PnP\" supposed to modify its own files?\n1. **Which script(s) should be set so that a package can be consistently installed and setup in all package managers?**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcinderblock%2Ftest-npm-yarn-lifecycle-scripts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcinderblock%2Ftest-npm-yarn-lifecycle-scripts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcinderblock%2Ftest-npm-yarn-lifecycle-scripts/lists"}