
Security News
The Code You Didn't Write Is Still Yours to Defend
AI agents are pulling packages into environments no scanner is watching, creating exposure before security teams can see it.
package-json-effect
Advanced tools
An Effect library for reading, writing, parsing, validating and normalizing package.json files. It decodes a file into a typed Package model — version becomes a SemVer, optional fields become Option, dependency maps become HashMap — and writes it back with consistent key ordering. Reading, formatting, validation and dependency resolution are each a swappable Layer, so you keep the parts you want and replace the rest.
Package model decoded from a package.json file: version is a SemVer, optional fields are Option, dependency and script maps are HashMapisScoped, isESM, isPrivate, hasDependency) and a dual-API for immutable mutations (data-first Package.setVersion(pkg, v), curried Package.setVersion(v)(pkg) and pipeable pkg.pipe(Package.setVersion(v)))Dependency, DevDependency, PeerDependency and OptionalDependency instances with a protocol taxonomy (isRange, isTag, isGit, isLocal, isWorkspace, isCatalog) that classifies any specifier@effect/platform FileSystem, with sort-package-json-style key ordering and alphabetical dependency sorting applied on writeValidationRule interface for writing your ownpackage-json-effect/schema entry point: extend the model with .extend() and rebuild the wire schema with makePackageJsonSchema to type custom fieldscatalog: and workspace: resolution through swappable CatalogResolver and WorkspaceResolver serviceseffect and @effect/platform are peer dependencies. Install them alongside a platform adapter for your runtime — @effect/platform-node for Node.js.
npm install package-json-effect effect @effect/platform @effect/platform-node
# or
pnpm add package-json-effect effect @effect/platform @effect/platform-node
Read a file, inspect it through the typed getters, make an immutable edit and write it back. The program yields the PackageJsonReader and PackageJsonWriter services and runs with the composite PackageJsonLive layer plus a FileSystem layer.
import { NodeFileSystem } from "@effect/platform-node";
import { Effect } from "effect";
import { Package, PackageJsonLive, PackageJsonReader, PackageJsonWriter } from "package-json-effect";
const program = Effect.gen(function* () {
const reader = yield* PackageJsonReader;
const writer = yield* PackageJsonWriter;
const pkg = yield* reader.read("./package.json");
console.log(pkg.name); // the "name" field, a string
console.log(pkg.version.toString()); // the "version" field as a SemVer, e.g. "1.3.0"
console.log(pkg.isESM); // true when "type": "module"
// Mutations return a new Package; the original is untouched.
const bumped = yield* Package.setVersion(pkg, "1.4.0");
const withDep = Package.addDependency(bumped, "effect", "^3.10.0");
yield* writer.write("./package.json", withDep);
});
Effect.runPromise(program.pipe(Effect.provide(PackageJsonLive), Effect.provide(NodeFileSystem.layer)));
PackageJsonLive provides every service in the library and requires FileSystem from @effect/platform, which NodeFileSystem.layer (or NodeContext.layer) supplies.
FAQs
Utility library for working with package.json files in Effect
The npm package package-json-effect receives a total of 6 weekly downloads. As such, package-json-effect popularity was classified as not popular.
We found that package-json-effect demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
AI agents are pulling packages into environments no scanner is watching, creating exposure before security teams can see it.

Security News
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.