{"id":17472636,"url":"https://github.com/shinnn/prepend-path","last_synced_at":"2026-04-20T06:05:33.190Z","repository":{"id":57329844,"uuid":"114110434","full_name":"shinnn/prepend-path","owner":"shinnn","description":"Prepend a path to the existing PATH environment variable cross-platform way","archived":false,"fork":false,"pushed_at":"2018-11-20T21:53:48.000Z","size":44,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-01T18:52:40.177Z","etag":null,"topics":["cross-platform","environment-variables","javascript","nodejs","path","prepend"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shinnn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-13T11:03:19.000Z","updated_at":"2018-11-20T21:53:49.000Z","dependencies_parsed_at":"2022-09-16T17:50:20.752Z","dependency_job_id":null,"html_url":"https://github.com/shinnn/prepend-path","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/shinnn/prepend-path","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Fprepend-path","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Fprepend-path/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Fprepend-path/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Fprepend-path/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shinnn","download_url":"https://codeload.github.com/shinnn/prepend-path/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Fprepend-path/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268657590,"owners_count":24285532,"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","status":"online","status_checked_at":"2025-08-04T02:00:09.867Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["cross-platform","environment-variables","javascript","nodejs","path","prepend"],"created_at":"2024-10-18T17:29:35.137Z","updated_at":"2025-10-16T18:27:38.056Z","avatar_url":"https://github.com/shinnn.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# prepend-path\n\n[![npm version](https://img.shields.io/npm/v/prepend-path.svg)](https://www.npmjs.com/package/prepend-path)\n[![Build Status](https://travis-ci.org/shinnn/prepend-path.svg?branch=master)](https://travis-ci.org/shinnn/prepend-path)\n[![Coverage Status](https://img.shields.io/coveralls/shinnn/prepend-path.svg)](https://coveralls.io/github/shinnn/prepend-path?branch=master)\n\nPrepend a path to the existing [`PATH`](http://pubs.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap08.html#tag_08_03) environment variable cross-platform way\n\n```javascript\nconst prependPath = require('prepend-path');\n\nprocess.env.PATH; //=\u003e '/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin'\n\nprependPath('additional/bin');\n\nprocess.env.PATH; //=\u003e 'additional/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin'\n```\n\n## Installation\n\n[Use](https://docs.npmjs.com/cli/install) [npm](https://docs.npmjs.com/getting-started/what-is-npm).\n\n```\nnpm install prepend-path\n```\n\n## API\n\n```javascript\nconst prependPath = require('prepend-path');\n```\n\n### prependPath(*path*)\n\n*path*: `string` (a path to prepend)  \nReturn: `string` (modified `PATH` environment variable)\n\nIt prepends the given *path* to the [`process.env.PATH`](https://nodejs.org/api/process.html#process_process_env), or [its equivalent on Windows](https://stackoverflow.com/questions/7199039/file-paths-in-windows-environment-not-case-sensitive/7199074#7199074) for example `process.env.Path`, along with [the platform-specific path delimiter](https://nodejs.org/api/path.html#path_path_delimiter).\n\n```javascript\nprependPath('foo/bar');\n// POSIX\n//=\u003e 'foo/bar:/usr/local/bin:/usr/bin:/bin:...'\n\n// Windows\n//=\u003e 'foo\\\\bar;C:\\\\Users\\\\appveyor\\\\AppData\\\\Roaming\\\\npm;C:\\\\...'\n```\n\nPrepending a new path to the `PATH` is, in other words, making it precedent to the every existing one while searching executable files.\n\n```javascript\nconst {existsSync} = require('fs');\nconst which = require('which');\n\nexistsSync('/User/example/new_path/npm/bin/npm'); //=\u003e true\n\nwhich.sync('npm'); //=\u003e '/usr/local/bin/npm'\nprependPath('/User/example/new_path/npm/bin');\nwhich.sync('npm'); //=\u003e '/User/example/new_path/npm/bin/npm'\n```\n\n## License\n\n[ISC License](./LICENSE) © 2017 - 2018 Shinnosuke Watanabe\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshinnn%2Fprepend-path","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshinnn%2Fprepend-path","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshinnn%2Fprepend-path/lists"}