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

read-pkg

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

read-pkg

Read a package.json file

  • 9.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
39M
decreased by-14.3%
Maintainers
1
Weekly downloads
 
Created

What is read-pkg?

The read-pkg npm package is used to read a package.json file and parse its contents. It can normalize the data according to the npm normalization rules, handle different file encodings, and can read from different locations by resolving the path to the nearest package.json file.

What are read-pkg's main functionalities?

Read package.json from the current directory

This feature reads the package.json file from the current working directory and outputs the parsed JSON object.

const readPkg = require('read-pkg');

(async () => {
  const pkg = await readPkg();
  console.log(pkg);
})();

Read package.json from a specified directory

This feature allows you to specify a directory from which to read the package.json file, rather than the current working directory.

const readPkg = require('read-pkg');

(async () => {
  const pkg = await readPkg({ cwd: 'path/to/directory' });
  console.log(pkg);
})();

Read and normalize package.json data

This feature reads the package.json file and normalizes its data according to npm normalization rules, which can be useful for ensuring consistent data structure.

const readPkg = require('read-pkg');

(async () => {
  const pkg = await readPkg({ normalize: true });
  console.log(pkg);
})();

Other packages similar to read-pkg

Keywords

FAQs

Package last updated on 02 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