Function readPackageJsonSync

  • Synchronously reads and parses a package.json file.

    Parameters

    • path: string = './package.json'

      The path to the package.json file. Defaults to './package.json'.

    • encoding: BufferEncoding = 'utf-8'

      The encoding to use when reading the file. Defaults to 'utf-8'.

    Returns PackageJson

    The parsed package.json content as a PackageJson object.

    If the JSON content is invalid.

    If the file cannot be read or does not exist.