Registry / data / update-package

update-package

JSON →
library0.2.0jsnpmunverified

A Node.js library (v0.2.0, last updated February 2015) for updating or linting a package.json file against a set of defaults. Originally designed to enforce consistent fields across multiple projects, it appears to read a template/defaults object and merge it into an existing package.json. The package is minimal, using only Node's built-in fs and path modules, and has no significant external dependencies. Its development cadence is very low (single release), and it has been largely superseded by more active tools like sort-package-json or npm-check. The project is now archived/unmaintained.

npm install update-package
INSTALL
IMPORT
SIG · UPDATE-PACKAGE
U
update-package
datajavascriptv0.2.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
const updatePkg = require('update-package')
import updatePkg from 'update-package'
Package uses CJS, no ESM export. Requires Node >=0.10.0.
none (callable)
const updatePkg = require('update-package')(defaults, pkg)
const updatePkg = new (require('update-package'))(defaults, pkg)
Function returns a modified package.json object; no constructor.
none (type)
const updatePkg = require('update-package')
No TypeScript types provided; use @types/update-package if available (not on DefinitelyTyped).

Shows how to require the package and use it to update a package.json object with default values.

const updatePkg = require('update-package'); const defaults = { name: 'my-app', version: '1.0.0' }; const pkg = { name: 'my-app', version: '0.9.0', private: true }; const result = updatePkg(defaults, pkg); console.log(result); // { name: 'my-app', version: '1.0.0', private: true }
Debug
Known issues
deprecatedPackage is unmaintained since 2015. Use modern alternatives like sort-package-json or npm init.
fix
Use sort-package-json or migrate to npm's built-in defaults.
affects: >=0.0.0
gotchaThe function mutates the first argument (defaults) and returns it; does not create a deep copy.
fix
Pass a shallow copy of defaults: updatePkg({...defaults}, pkg)
affects: <=0.2.0
gotchaOnly works with CommonJS require; not ESM compatible and no dual build.
fix
Use dynamic import or rewrite to use require.
affects: <=0.2.0
deprecatedNo longer maintained; known issues with npm v2+ and newer Node versions may cause unexpected behavior.
fix
Switch to a maintained alternative.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'update-package'
Package not installed or npm install failed.
fix
Run 'npm install update-package'
TypeError: updatePkg is not a function
Using ES6 import syntax with CJS package.
fix
Use 'const updatePkg = require('update-package')' instead of 'import updatePkg from ...'.
TypeError: Cannot read property 'name' of undefined
Missing or invalid defaults object as first argument.
fix
Ensure first argument is an object with required fields.
Upgrade
Version history
0.2.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
18 hits · last 30 days
node
14
OpenAI (training)
2
Resources
update-package — npm install update-package · libregistry