{"_id":"package-config","_rev":"4665502","name":"package-config","description":"Get namespaced config from the closest package.json","dist-tags":{"latest":"5.0.0"},"maintainers":[{"name":"sindresorhus","email":""}],"time":{"modified":"2026-04-10T22:38:38.000Z","created":"2015-01-09T07:20:14.757Z","5.0.0":"2023-11-05T19:11:49.145Z","0.1.0":"2015-01-09T07:20:14.757Z"},"users":{},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"repository":{"type":"git","url":"git+https://github.com/sindresorhus/package-config.git"},"versions":{"5.0.0":{"name":"package-config","version":"5.0.0","description":"Get namespaced config from the closest package.json","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/package-config.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"types":"./index.d.ts","default":"./index.js"},"sideEffects":false,"engines":{"node":">=18"},"scripts":{"test":"xo && ava && tsd"},"keywords":["json","read","parse","file","fs","graceful","load","package","config","configuration","object","namespace","namespaced"],"dependencies":{"find-up-simple":"^1.0.0","load-json-file":"^7.0.1"},"devDependencies":{"ava":"^5.3.1","tsd":"^0.29.0","xo":"^0.56.0"},"fixture":{"foo":true},"types":"./index.d.ts","gitHead":"06c7e264cafe44df72cf3c6cfb4b29eee4fb7a3f","bugs":{"url":"https://github.com/sindresorhus/package-config/issues"},"homepage":"https://github.com/sindresorhus/package-config#readme","_id":"package-config@5.0.0","_nodeVersion":"20.9.0","_npmVersion":"9.2.0","dist":{"shasum":"cba78b7feb3396fa0149caca2c72677ff302b3c4","size":3051,"noattachment":false,"key":"/package-config/-/package-config-5.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/package-config/download/package-config-5.0.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/package-config_5.0.0_1699211508961_0.3770151924868308"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2023-11-05T19:11:49.145Z","publish_time":1699211509145,"_source_registry_name":"default","_cnpm_publish_time":1699211509145},"0.1.0":{"name":"package-config","version":"0.1.0","description":"Node.js config loader based on package.json file.","main":"index.js","scripts":{"test":"mocha test -R spec --colors --bail"},"repository":{"type":"git","url":"https://github.com/leorossi/node-package-config.git"},"keywords":["package.json","config","environments"],"author":{"name":"Leonardo Rossi","email":"leonardo.rossi@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/leorossi/node-package-config/issues"},"homepage":"https://github.com/leorossi/node-package-config","devDependencies":{"should":"^4.4.2"},"gitHead":"cac70fec290e90029d890538421170304091c66c","_id":"package-config@0.1.0","_shasum":"87950ceb37723cecafca29650c24f790f2739d4f","_from":"./","_npmVersion":"1.4.28","_npmUser":{"name":"leorossi","email":"leonardo.rossi@gmail.com"},"maintainers":[{"name":"sindresorhus","email":""}],"dist":{"shasum":"87950ceb37723cecafca29650c24f790f2739d4f","size":2638,"noattachment":false,"key":"/package-config/-/package-config-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/package-config/download/package-config-0.1.0.tgz"},"directories":{},"_cnpmcore_publish_time":"2021-12-23T15:23:37.507Z","publish_time":1420788014757,"_cnpm_publish_time":1420788014757}},"readme":"# package-config\n\n> Get namespaced config from the closest package.json\n\nHaving tool specific config in package.json reduces the amount of metafiles in your repo (there are usually a lot!) and makes the config obvious compared to hidden dotfiles like `.eslintrc`, which can end up causing confusion. [XO](https://github.com/xojs/xo), for example, uses the `xo` namespace in package.json, and [ESLint](http://eslint.org) uses `eslintConfig`. Many more tools supports this, like [AVA](https://avajs.dev), [Babel](https://babeljs.io), [nyc](https://github.com/istanbuljs/nyc), etc.\n\n## Install\n\n```sh\nnpm install package-config\n```\n\n## Usage\n\n```json\n{\n\t\"name\": \"some-package\",\n\t\"version\": \"1.0.0\",\n\t\"unicorn\": {\n\t\t\"rainbow\": true\n\t}\n}\n```\n\n```js\nimport {packageConfig} from 'package-config';\n\nconst config = await packageConfig('unicorn');\n\nconsole.log(config.rainbow);\n//=> true\n```\n\n## API\n\nIt [walks up](https://github.com/sindresorhus/find-up-simple) parent directories until a `package.json` can be found, reads it, and returns the user specified namespace or an empty object if not found.\n\n### packageConfig(namespace, options?)\n\nReturns a `Promise` for the config.\n\n### packageConfigSync(namespace, options?)\n\nReturns the config.\n\n#### namespace\n\nType: `string`\n\nThe package.json namespace you want.\n\n#### options\n\nType: `object`\n\n##### cwd\n\nType: `string`\\\nDefault: `process.cwd()`\n\nThe directory to start looking up for a package.json file.\n\n##### defaults\n\nType: `object`\n\nThe default config.\n\n##### skipOnFalse\n\nType: `boolean`\\\nDefault: `false`\n\nSkip `package.json` files that have the namespaced config explicitly set to `false`.\n\nContinues searching upwards until the next `package.json` file is reached. This can be useful when you need to support the ability for users to have nested `package.json` files, but only read from the root one, like in the case of [`electron-builder`](https://github.com/electron-userland/electron-builder/wiki/Options#AppMetadata) where you have one `package.json` file for the app and one top-level for development.\n\nExample usage for the user:\n\n```json\n{\n\t\"name\": \"some-package\",\n\t\"version\": \"1.0.0\",\n\t\"unicorn\": false\n}\n```\n\n### packageJsonPath(config)\n\nPass in the config returned from any of the above methods.\n\nReturns the file path to the package.json file or `undefined` if not found.\n\n## Related\n\n- [read-package-up](https://github.com/sindresorhus/read-package-up) - Read the closest package.json file\n- [read-pkg](https://github.com/sindresorhus/read-pkg) - Read a package.json file\n- [find-up](https://github.com/sindresorhus/find-up) - Find a file by walking up parent directories\n","_attachments":{},"homepage":"https://github.com/sindresorhus/package-config#readme","bugs":{"url":"https://github.com/sindresorhus/package-config/issues"},"license":"MIT"}