write-pkg
    TypeScript icon, indicating that this package has built-in type declarations

    5.0.0 • Public • Published

    write-pkg

    Write a package.json file

    Writes atomically and creates directories for you as needed. Sorts dependencies when writing. Preserves the indentation if the file already exists.

    Install

    $ npm install write-pkg
    

    Usage

    import path from 'node:path';
    import {writePackage} from 'write-pkg';
    
    await writePackage({foo: true});
    console.log('done');
    
    await writePackage(path.join('unicorn', 'package.json'), {foo: true});
    console.log('done');

    API

    writePackage(path?, data, options?)

    Returns a Promise.

    writePackageSync(path?, data, options?)

    path

    Type: string
    Default: process.cwd()

    The path to where the package.json file should be written or its directory.

    options

    Type: object

    normalize

    Type: boolean
    Default: true

    Remove empty dependencies, devDependencies, optionalDependencies and peerDependencies objects.

    write-pkg for enterprise

    Available as part of the Tidelift Subscription.

    The maintainers of write-pkg and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.

    Related

    Install

    npm i write-pkg

    DownloadsWeekly Downloads

    1,153,941

    Version

    5.0.0

    License

    MIT

    Unpacked Size

    6.69 kB

    Total Files

    5

    Last publish

    Collaborators

    • sindresorhus