1. read-pkg
Read a package.json file
read-pkg
Package: read-pkg
Created by: sindresorhus
Last modified: Thu, 16 Nov 2023 08:39:25 GMT
Version: 9.0.1
License: MIT
Downloads: 149,218,161
Repository: https://github.com/sindresorhus/read-pkg

Install

npm install read-pkg
yarn add read-pkg

read-pkg

Read a package.json file

Why

Install

 npm install read-pkg

Usage

 import {readPackage} from 'read-pkg';

console.log(await readPackage());
//=> {name: 'read-pkg', …}

console.log(await readPackage({cwd: 'some-other-directory'}));
//=> {name: 'unicorn', …}

API

readPackage(options?)

Returns a Promise<object> with the parsed JSON.

readPackageSync(options?)

Returns the parsed JSON.

options

Type: object

cwd

Type: URL | string
Default: process.cwd()

Current working directory.

normalize

Type: boolean
Default: true

Normalize the package data.

parsePackage(packageFile, options?)

Parses an object or string into JSON.

packageFile

Type: object | string

An object or a stringified object to be parsed as a package.json.

options

Type: object

normalize

Type: boolean
Default: true

Normalize the package data.

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin