{"id":20380497,"url":"https://github.com/tobua/skip-local-postinstall","last_synced_at":"2025-04-12T08:34:15.661Z","repository":{"id":57362386,"uuid":"293130867","full_name":"tobua/skip-local-postinstall","owner":"tobua","description":"Skip postinstall on local npm installs.","archived":false,"fork":false,"pushed_at":"2022-11-12T09:17:00.000Z","size":28,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-26T03:41:41.648Z","etag":null,"topics":["local","npm","postinstall","skip"],"latest_commit_sha":null,"homepage":"https://npmjs.com/skip-local-postinstall","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/tobua.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}},"created_at":"2020-09-05T18:17:14.000Z","updated_at":"2022-04-11T18:43:51.000Z","dependencies_parsed_at":"2023-01-21T14:15:08.192Z","dependency_job_id":null,"html_url":"https://github.com/tobua/skip-local-postinstall","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobua%2Fskip-local-postinstall","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobua%2Fskip-local-postinstall/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobua%2Fskip-local-postinstall/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobua%2Fskip-local-postinstall/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tobua","download_url":"https://codeload.github.com/tobua/skip-local-postinstall/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248540762,"owners_count":21121412,"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":["local","npm","postinstall","skip"],"created_at":"2024-11-15T02:07:30.773Z","updated_at":"2025-04-12T08:34:15.642Z","avatar_url":"https://github.com/tobua.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# skip-local-postinstall\n\nSkips (successfully exits current process) when postinstall is called locally instead of being called when the package has been published to npm.\n\n```js\n// package.json\n\"scripts\": {\n  \"postinstall\": \"node ./installation.js\"\n}\n```\n\n```js\n// installation.js\nimport { skip } from 'skip-local-postinstall'\n\nskip()\n\n// This code will only be executed when installed through npm.\nconsole.log('Installing from npm.')\n```\n\nRequires [`process.env.INIT_CWD`](https://github.com/npm/cli/issues/2033) variable available in all stable npm releases. Credits to Már Örlygsson for suggesting this implementaiton on [Stackoverflow](https://stackoverflow.com/a/53239387/3185545s).\n\n## Compiled Postinstall File\n\nIn cases where you want to run a postinstall script for compiled files (i.e. source in TypeScript) the file will not be there when installing the package locally. To address that this plugin also includes a bin script. It's arguments will be passed directly to the `node` command and can include additional arguments apart from the file to run.\n\n```js\n// package.json\n\"scripts\": {\n  \"postinstall\": \"skip-local-postinstall ./dist/installation.js\"\n}\n```\n\n## Alternative\n\nIt's also possible to encapsulate som of the desired functionality in a one-line script. However, this only works when the script is the result of a build process and the build is removed before installation.\n\n```js\n// package.json\n\"scripts\": {\n  \"postinstall\": \"node -e \\\"try{import('./dist/postinstall.js')}catch(e){}\\\"\"\n}\n```\n\nWhen using a CommonJS package without `{ type: \"module\" }` in package.json a require call can be used.\n\n```js\n\"node -e \\\"try{require('./dist/postinstall.js')}catch(e){}\\\"\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftobua%2Fskip-local-postinstall","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftobua%2Fskip-local-postinstall","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftobua%2Fskip-local-postinstall/lists"}