Socket
Socket
Sign inDemoInstall

normalize-package-data

Package Overview
Dependencies
1
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    normalize-package-data

Normalizes data that can be found in package.json files.


Version published
Weekly downloads
41M
decreased by-2.96%
Maintainers
1
Created
Weekly downloads
 

Package description

What is normalize-package-data?

The normalize-package-data npm package is used to normalize the metadata of a package.json file according to the npm and Node.js specifications. This includes cleaning up various fields, ensuring required fields are present, and providing default values where appropriate.

What are normalize-package-data's main functionalities?

Normalization of package metadata

This feature takes a package.json object and normalizes its metadata. After normalization, the package object is modified in place to meet the standard structure and fields as defined by npm and Node.js.

const normalize = require('normalize-package-data');
let pkg = { name: 'example', version: '1.0.0' };
normalize(pkg);
console.log(pkg);

Validation of package data

The package also validates the package data and attaches an array of error messages to the package object if there are any issues found during normalization.

const normalize = require('normalize-package-data');
let pkg = { name: 'example', version: '1.0.0' };
normalize(pkg);
if (pkg.errors) {
  console.error('Package data contains errors:', pkg.errors);
}

Warning for non-standard fields

If the package data contains non-standard fields, the normalization process will not remove them but will provide warnings about their presence.

const normalize = require('normalize-package-data');
let pkg = { name: 'example', version: '1.0.0', nonStandardField: 'some value' };
normalize(pkg);
if (pkg.warnings) {
  console.warn('Package data contains warnings:', pkg.warnings);
}

Other packages similar to normalize-package-data

Readme

Source

read-package-data

This code is based on read-package-json by Isaac Schlueter.

FAQs

Last updated on 09 Apr 2013

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc