get-package-name
TypeScript icon, indicating that this package has built-in type declarations

2.2.0 • Public • Published

Get Package Name

GitHub license Build Status npm version

Extracts the name of a package from its file path.

const getPackageName = require('get-package-name')
getPackageName('./project/node_modules/@babel/parser/lib/index.js') // @babel/parser

Installation

This is a Node.js package available through the npm registry. Before installing, download and install Node.js. Node.js 12 or higher is required.

Installation is done using the npm install command:

$ npm install --save-dev get-package-name

API

getPackageName(modulePath, [moduleFolder])

Returns the package name for the given module file path.

modulePath

An absolute or relative path to a module.

moduleFolder

The name of the folder in which packages are installed. Defaults to "node_modules".

License

This package is MIT licensed.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 2.2.0
    80,496
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 2.2.0
    80,496
  • 2.1.0
    3
  • 2.0.0
    0
  • 1.1.0
    173
  • 1.0.0
    1

Package Sidebar

Install

npm i get-package-name

Weekly Downloads

80,673

Version

2.2.0

License

MIT

Unpacked Size

4.25 kB

Total Files

5

Last publish

Collaborators

  • i-like-robots