Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

write-pkg

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

write-pkg

Write a package.json file

  • 7.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.4M
increased by4.5%
Maintainers
1
Weekly downloads
 
Created

What is write-pkg?

The write-pkg npm package is used to write a package.json file. It allows you to create or update the package.json file programmatically, which can be useful for automating project setup or configuration tasks.

What are write-pkg's main functionalities?

Write a new package.json file

This feature allows you to create a new package.json file with the specified content. The code sample demonstrates how to write a new package.json file with basic fields like name, version, and description.

const writePkg = require('write-pkg');

writePkg({
  name: 'awesome-package',
  version: '1.0.0',
  description: 'My awesome package'
}).then(() => {
  console.log('package.json written successfully');
});

Update an existing package.json file

This feature allows you to update an existing package.json file. The code sample demonstrates how to update the version field of an existing package.json file.

const writePkg = require('write-pkg');

writePkg({
  version: '1.0.1'
}, {cwd: '.'}).then(() => {
  console.log('package.json updated successfully');
});

Write a package.json file with nested properties

This feature allows you to write a package.json file with nested properties. The code sample demonstrates how to include nested properties like scripts in the package.json file.

const writePkg = require('write-pkg');

writePkg({
  name: 'awesome-package',
  version: '1.0.0',
  scripts: {
    start: 'node index.js',
    test: 'npm test'
  }
}).then(() => {
  console.log('package.json with nested properties written successfully');
});

Other packages similar to write-pkg

Keywords

FAQs

Package last updated on 04 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc