https://github.com/bukinoshita/read-package
Reads package.json in the working directory
https://github.com/bukinoshita/read-package
javascript json nodejs npm package read read-package
Last synced: 5 months ago
JSON representation
Reads package.json in the working directory
- Host: GitHub
- URL: https://github.com/bukinoshita/read-package
- Owner: bukinoshita
- License: mit
- Created: 2017-06-16T06:17:54.000Z (about 9 years ago)
- Default Branch: main
- Last Pushed: 2023-01-04T21:47:23.000Z (over 3 years ago)
- Last Synced: 2025-10-23T02:16:14.785Z (8 months ago)
- Topics: javascript, json, nodejs, npm, package, read, read-package
- Language: TypeScript
- Homepage:
- Size: 620 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 10
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# read-package [](https://travis-ci.org/bukinoshita/read-package)
> Reads [package.json](https://docs.npmjs.com/files/package.json) in the working directory.
## Install
```
$ yarn add read-package
```
## Usage
```
.
├── foo
│ └── ...
└── bar
└── package.json
```
```js
const readPackage = require('read-package')
readPackage('foo')
//=> package.json not found in the current project.
readPackage('bar')
//=> { "name": "fixture", "version": "1.0.0" }
```
## API
### readPackage([cwd])
Returns an `object` or `throws an error`.
#### cwd
Type: `string`
Default: `process.cwd()`
Current working directory.
## Related
- [has-package](https://github.com/bukinoshita/has-package) — Check if a project has package.json
## License
MIT © [Bu Kinoshita](https://bukinoshita.com)