This is a helper for reading and parsing package json files
npm install @map-colonies/read-pkgA lightweight utility to read and parse package.json files synchronously.
``bash`
npm install @mapcolonies/read-pkg
`typescript
import { readPackageJsonSync } from '@map-colonies/read-pkg';
// Read package.json from current directory
const packageJson = readPackageJsonSync();
console.log(packageJson.name);
// Read package.json from specific path
const otherPackageJson = readPackageJsonSync('./path/to/package.json');
console.log(otherPackageJson.version);
`
Synchronously reads and parses a package.json file.
#### Parameters
- path (optional): Path to the package.json file. Defaults to './package.json'encoding
- (optional): File encoding to use. Defaults to 'utf-8'
#### Returns
Returns a PackageJson object from the type-fest package.
#### Throws
- SyntaxError: If the JSON content is invalidError`: If the file cannot be read or does not exist
-