{"_id":"write-package","_rev":"4-f5c80cd0e9ab99ed29db026a968d02bc","name":"write-package","dist-tags":{"latest":"7.2.0"},"versions":{"7.0.0":{"name":"write-package","version":"7.0.0","keywords":["json","write","stringify","file","fs","graceful","package"],"author":{"url":"https://sindresorhus.com","name":"Sindre Sorhus","email":"sindresorhus@gmail.com"},"license":"MIT","_id":"write-package@7.0.0","maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"homepage":"https://github.com/sindresorhus/write-package#readme","bugs":{"url":"https://github.com/sindresorhus/write-package/issues"},"ava":{"nodeArguments":["--loader=esmock","--no-warnings=ExperimentalWarning"]},"dist":{"shasum":"2b4ff2b79026f232c9d2830eb0df8beb67ce0c9b","tarball":"https://registry.npmjs.org/write-package/-/write-package-7.0.0.tgz","fileCount":9,"integrity":"sha512-4hrl8mh5DmsmFSEnSzGC5sWzuL8slwcxtdLrHfah4zSetriKwxKkKX6vRskGJq4qvwiLXEwBmv9i+xU64SAncg==","signatures":[{"sig":"MEYCIQDD0qsppguT9/smw0fEafm+ptywaM7L2E3ms92V+eyQuAIhAKkCkm8HsswXeypBzh5FuPn93lrEG/7J3q2b/elR3nTI","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19793},"type":"module","types":"./index.d.ts","engines":{"node":">=18"},"exports":{"types":"./index.d.ts","default":"./index.js"},"funding":"https://github.com/sponsors/sindresorhus","gitHead":"5cb282f68787098795420764057dc436abe58211","scripts":{"test":"xo && ava && tsd"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"repository":{"url":"git+https://github.com/sindresorhus/write-package.git","type":"git"},"_npmVersion":"9.2.0","description":"Write a package.json file","directories":{},"_nodeVersion":"18.18.2","dependencies":{"read-pkg":"^9.0.0","sort-keys":"^5.0.0","type-fest":"^4.6.0","deepmerge-ts":"^5.1.0","write-json-file":"^5.0.0"},"_hasShrinkwrap":false,"devDependencies":{"xo":"^0.56.0","ava":"^5.3.1","tsd":"^0.29.0","tempy":"^3.1.0","esmock":"^2.5.9","filter-anything":"^3.0.7"},"_npmOperationalInternal":{"tmp":"tmp/write-package_7.0.0_1699093083445_0.6800637349283527","host":"s3://npm-registry-packages"}},"7.0.1":{"name":"write-package","version":"7.0.1","keywords":["json","write","stringify","file","fs","graceful","package"],"author":{"url":"https://sindresorhus.com","name":"Sindre Sorhus","email":"sindresorhus@gmail.com"},"license":"MIT","_id":"write-package@7.0.1","maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"homepage":"https://github.com/sindresorhus/write-package#readme","bugs":{"url":"https://github.com/sindresorhus/write-package/issues"},"ava":{"nodeArguments":["--loader=esmock","--no-warnings=ExperimentalWarning"]},"dist":{"shasum":"29b848298334515c31dc152d26725ff8b142ae44","tarball":"https://registry.npmjs.org/write-package/-/write-package-7.0.1.tgz","fileCount":9,"integrity":"sha512-S7c5F2mpb5o+9pS1UfO3jcQb0OR25L7ZJT64cv3K0TkGh1VxJb+PNnL8b46KSJ6tmxIbA0xgHnrtBdVGeHmJ0A==","signatures":[{"sig":"MEUCIQDfBUA6TfcMkTCB22BEL8/UV8RXsBrlY9eUHGGdkm9VsQIgH2YUcoT8Gsfc5+mK3LOkd5aIxqjwJcOwRk20N+Rm+y4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19924},"type":"module","types":"./index.d.ts","engines":{"node":">=18"},"exports":{"types":"./index.d.ts","default":"./index.js"},"funding":"https://github.com/sponsors/sindresorhus","gitHead":"f306fd3a13ed774e3212a6233a0c84d72bd25f1e","scripts":{"test":"xo && ava && tsd"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"repository":{"url":"git+https://github.com/sindresorhus/write-package.git","type":"git"},"_npmVersion":"9.2.0","description":"Write a package.json file","directories":{},"sideEffects":false,"_nodeVersion":"21.6.2","dependencies":{"read-pkg":"^9.0.0","sort-keys":"^5.0.0","type-fest":"^4.6.0","deepmerge-ts":"^5.1.0","write-json-file":"^5.0.0"},"_hasShrinkwrap":false,"devDependencies":{"xo":"^0.56.0","ava":"^5.3.1","tsd":"^0.29.0","tempy":"^3.1.0","esmock":"^2.5.9","filter-anything":"^3.0.7"},"_npmOperationalInternal":{"tmp":"tmp/write-package_7.0.1_1708933265952_0.20356497015759567","host":"s3://npm-registry-packages"}},"7.1.0":{"name":"write-package","version":"7.1.0","keywords":["json","write","stringify","file","fs","graceful","package"],"author":{"url":"https://sindresorhus.com","name":"Sindre Sorhus","email":"sindresorhus@gmail.com"},"license":"MIT","_id":"write-package@7.1.0","maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"homepage":"https://github.com/sindresorhus/write-package#readme","bugs":{"url":"https://github.com/sindresorhus/write-package/issues"},"ava":{"nodeArguments":["--loader=esmock","--no-warnings=ExperimentalWarning"]},"dist":{"shasum":"d5466625606e23a3c740919a324dfd7f41bf0e4f","tarball":"https://registry.npmjs.org/write-package/-/write-package-7.1.0.tgz","fileCount":9,"integrity":"sha512-DqUx8GI3r9BFWwU2DPKddL1E7xWfbFED82mLVhGXKlFEPe8IkBftzO7WfNwHtk7oGDHDeuH/o8VMpzzfMwmLUA==","signatures":[{"sig":"MEQCIGpp/xKFVHnzzQOa0t01sa09E3mNPaYuE5zsrMq+KZUpAiBSC4N7NRiYQaqnGCYH47FG5HYV/9/5tCCWCMlknSdRxQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20065},"type":"module","types":"./index.d.ts","engines":{"node":">=18"},"exports":{"types":"./index.d.ts","default":"./index.js"},"funding":"https://github.com/sponsors/sindresorhus","gitHead":"9f44ea9e0b706675bd506b0bc549958dd2557a02","scripts":{"test":"xo && ava && tsd"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"repository":{"url":"git+https://github.com/sindresorhus/write-package.git","type":"git"},"_npmVersion":"10.6.0","description":"Write a package.json file","directories":{},"sideEffects":false,"_nodeVersion":"18.20.2","dependencies":{"read-pkg":"^9.0.1","sort-keys":"^5.0.0","type-fest":"^4.23.0","deepmerge-ts":"^7.1.0","write-json-file":"^6.0.0"},"_hasShrinkwrap":false,"devDependencies":{"xo":"^0.59.2","ava":"^6.1.3","tsd":"^0.31.1","tempy":"^3.1.0","esmock":"^2.6.7","filter-anything":"^4.0.2"},"_npmOperationalInternal":{"tmp":"tmp/write-package_7.1.0_1721993238357_0.20378685830890841","host":"s3://npm-registry-packages"}},"7.2.0":{"name":"write-package","version":"7.2.0","description":"Write a package.json file","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/write-package.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","write","stringify","file","fs","graceful","package"],"dependencies":{"deepmerge-ts":"^7.1.0","read-pkg":"^9.0.1","sort-keys":"^5.0.0","type-fest":"^4.23.0","write-json-file":"^6.0.0"},"devDependencies":{"ava":"^6.1.3","esmock":"^2.6.7","filter-anything":"^4.0.2","tempy":"^3.1.0","tsd":"^0.31.1","xo":"^0.59.2"},"ava":{"nodeArguments":["--loader=esmock","--no-warnings=ExperimentalWarning"]},"_id":"write-package@7.2.0","gitHead":"6797091ffdbee30f1ca87af35abb171c432bf6b1","types":"./index.d.ts","bugs":{"url":"https://github.com/sindresorhus/write-package/issues"},"homepage":"https://github.com/sindresorhus/write-package#readme","_nodeVersion":"20.19.1","_npmVersion":"10.9.2","dist":{"integrity":"sha512-uMQTubF/vcu+Wd0b5BGtDmiXePd/+44hUWQz2nZPbs92/BnxRo74tqs+hqDo12RLiEd+CXFKUwxvvIZvtt34Jw==","shasum":"d84e5a0dfe92cb7d17399adc8c083d38671cd871","tarball":"https://registry.npmjs.org/write-package/-/write-package-7.2.0.tgz","fileCount":9,"unpackedSize":21692,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIEv/q+beAmI16XcmcVMXyXKpzYMah8msig0sqAhsswDDAiB2/wt4IDbQtMoPPTKlq64zG9B0sSiZEUvekryHrbn1Lw=="}]},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/write-package_7.2.0_1757585883781_0.32198459687443903"},"_hasShrinkwrap":false}},"time":{"created":"2023-11-04T10:18:03.444Z","modified":"2025-09-11T10:18:04.102Z","7.0.0":"2023-11-04T10:18:03.658Z","7.0.1":"2024-02-26T07:41:06.123Z","7.1.0":"2024-07-26T11:27:18.523Z","7.2.0":"2025-09-11T10:18:03.946Z"},"bugs":{"url":"https://github.com/sindresorhus/write-package/issues"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"license":"MIT","homepage":"https://github.com/sindresorhus/write-package#readme","keywords":["json","write","stringify","file","fs","graceful","package"],"repository":{"type":"git","url":"git+https://github.com/sindresorhus/write-package.git"},"description":"Write a package.json file","maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"readme":"# write-package\n\n> Write a `package.json` file\n\nWrites atomically and creates directories for you as needed. Sorts dependencies when writing. Preserves the indentation if the file already exists.\n\n## Install\n\n```sh\nnpm install write-package\n```\n\n## Usage\n\n```js\nimport path from 'node:path';\nimport {writePackage} from 'write-package';\n\nawait writePackage({foo: true});\nconsole.log('done');\n\nawait writePackage(path.join('unicorn', 'package.json'), {foo: true});\nconsole.log('done');\n```\n\n## API\n\n### writePackage(path?, data, options?)\n\nReturns a `Promise` that resolves when the `package.json` file has been written.\n\n### writePackageSync(path?, data, options?)\n\n#### path\n\nType: `string`\\\nDefault: `process.cwd()`\n\nThe path to where the `package.json` file should be written or its directory.\n\n#### data\n\nType `object`\n\nJSON data to write to the `package.json` file.\n\n#### options\n\nType: `object`\n\nSee [Options](#options-4).\n\n### updatePackage(path?, data, options?)\n\nReturns a `Promise` that resolves when the `package.json` file has been updated.\n\n### updatePackageSync(path?, data, options?)\n\n```js\nimport {updatePackage} from 'write-package';\n\nawait updatePackage({foo: true});\n//=> { \"foo\": true }\n\nawait updatePackage({foo: false, bar: true});\n//=> { \"foo\": false, \"bar\": true }\n```\n\n#### path\n\nType: `string`\\\nDefault: `process.cwd()`\n\nThe path to where the `package.json` file should be written or its directory.\n\n#### data\n\nType `object`\n\nJSON data to write to the `package.json` file. If the file already exists, existing fields will be merged with the values in `data`.\n\n#### options\n\nType: `object`\n\nSee [Options](#options-4).\n\n### addPackageDependencies(path?, dependencies, options?)\n\nReturns a `Promise` that resolves when the `package.json` file has been written.\n\n### addPackageDependenciesSync(path?, dependencies, options?)\n\n```js\nimport {writePackage, addPackageDependencies} from 'write-package';\n\nawait writePackage({foo: true});\n//=> { \"foo\": true }\n\nawait addPackageDependencies({foo: '1.0.0'});\n//=> { \"foo\": true, \"dependencies\": { \"foo\": \"1.0.0\" } }\n\nawait addPackageDependencies({dependencies: {foo: '1.0.0'}, devDependencies: {bar: '1.0.0'}});\n//=> { \"foo\": true, \"dependencies\": { \"foo\": \"1.0.0\" }, \"devDependencies\": { \"bar\": \"1.0.0\" } }\n```\n\n#### path\n\nType: `string`\\\nDefault: `process.cwd()`\n\nThe path to where the `package.json` file should be written or its directory.\n\n#### dependencies\n\nType: `Record<string, string> | Partial<Record<'dependencies' | 'devDependencies' | 'optionalDependencies' | 'peerDependencies', Record<string, string>>>`\n\nDependencies to add to the `package.json` file.\n\n#### options\n\nType: `object`\n\nSee [Options](#options-4).\n\n### removePackageDependencies(path?, dependencies, options?)\n\nReturns a `Promise` that resolves when the `package.json` file has been written. Does not throw if the file does not exist.\n\n### removePackageDependenciesSync(path?, dependencies, options?)\n\n```js\nimport {writePackage, removePackageDependencies} from 'write-package';\n\nawait writePackage({foo: true, dependencies: {foo: '1.0.0'}, devDependencies: {bar: '1.0.0'}});\n//=> { \"foo\": true, \"dependencies\": { \"foo\": \"1.0.0\" }, \"devDependencies\": { \"bar\": \"1.0.0\" } }\n\nawait removePackageDependencies(['foo']);\n//=> { \"foo\": true, \"devDependencies\": { \"bar\": \"1.0.0\" } }\n\nawait removePackageDependencies({devDependencies: ['bar']});\n//=> { \"foo\": true }\n```\n\n#### path\n\nType: `string`\\\nDefault: `process.cwd()`\n\nThe path to where the `package.json` file should be written or its directory.\n\n#### dependencies\n\nType `string[] | Partial<Record<'dependencies' | 'devDependencies' | 'optionalDependencies' | 'peerDependencies', string[]>>`\n\nDependencies to remove from the `package.json` file.\n\n#### options\n\nType: `object`\n\nSee [Options](#options-4).\n\n### Options\n\n##### indent\n\nType: `string | number`\\\nDefault: Auto-detected or `'\\t'`\n\nThe indentation to use for new files.\n\nAccepts `'\\t'` for tab indentation or a number of spaces.\n\nIf the file already exists, the existing indentation will be used.\n\n##### detectIndent\n\nType: `boolean`\\\nDefault: `true`\n\nDetect indentation automatically if the file exists.\n\n##### normalize\n\nType: `boolean`\\\nDefault: `true`\n\nRemove empty `dependencies`, `devDependencies`, `optionalDependencies` and `peerDependencies` objects.\n\n## Related\n\n- [read-pkg](https://github.com/sindresorhus/read-pkg) - Read a `package.json` file\n- [write-json-file](https://github.com/sindresorhus/write-json-file) - Stringify and write JSON to a file atomically\n","readmeFilename":"readme.md"}