Use when working with npm, package.json, npm install, npm publish, npm workspaces, npm dependency management, npm scripts, package metadata, lockfiles, or registry publishing. Covers official npm CLI practices for installs, metadata, workspaces, publishing, and common dependency pitfalls.
Use this skill when creating, maintaining, or reviewing projects that use npm as the package manager.
This skill is based on the official npm documentation at:
This skill covers:
package.json metadata correctlypackage.json as the source of truth for allowed version ranges and package-lock.json as the source of truth for exact resolved versions.npm ci instead of npm install in CI when you need strict lockfile fidelity and reproducible installs.dependencies and development-only tooling in devDependencies.peerDependencies for plugin or host-package compatibility, and keep peer ranges broad when semver compatibility allows it.peerDependenciesMeta to mark optional peer integrations instead of forcing every consumer to install them.optionalDependencies only when your code can genuinely continue to work without them.overrides at the project root to pin or replace vulnerable or incompatible transitive dependencies.name and version.description, keywords, homepage, bugs, repository, and license.private: true for projects that should never be published.publishConfig when publish-time registry, access, or tag settings must be constrained.repository to avoid publish warnings.files deliberately so published tarballs contain only what consumers need.exports to define the supported public surface of a package when appropriate.bin correctly and ensure the target file starts with #!/usr/bin/env node.npm install updates the lockfile when declared ranges and locked versions no longer agree.--save-dev, --save-peer, --save-optional, and --no-save intentionally rather than relying on defaults when the dependency role matters.--save-exact when your workflow requires exact dependency specs instead of npm's default semver range behavior.--omit and --include to control what lands on disk without changing logical dependency resolution.--ignore-scripts or --dry-run when auditing or testing install behavior safely.package.json using explicit paths or globs.npm init -w <path> to create and register a workspace consistently.npm install <pkg> -w <workspace>.--workspace or --workspaces rather than manual directory loops.--if-present when running scripts across multiple workspaces that may not all define the same script.workspaces array..npmignore, .gitignore, and the files field carefully to control publish contents.dependencies instead of devDependencies.private: true is the simplest guard against accidental publication.npm install is equivalent to npm ci in CI or release workflows.peerDependencies ranges that create avoidable install conflicts.files, .npmignore, and generated artifacts were not reviewed.bin and directories.bin, which npm treats as an error.{
"name": "my-app",
"private": true,
"version": "1.0.0",
"scripts": {
"dev": "node server.js",
"test": "node --test"
},
"dependencies": {
"express": "^5.0.0"
},
"devDependencies": {
"typescript": "^5.0.0"
}
}
{
"name": "@acme/widgets",
"version": "1.2.0",
"description": "Reusable widget primitives",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/acme/widgets.git"
},
"files": [
"dist",
"README.md"
],
"exports": {
".": "./dist/index.js"
}
}
{
"name": "acme-monorepo",
"private": true,
"workspaces": [
"packages/*"
]
}
Useful commands:
npm init -w ./packages/core
npm install lodash -w core
npm run test --workspaces --if-present
{
"overrides": {
"some-transitive-package": "1.2.3"
}
}
package.json?npm ci instead of npm install for this workflow?private: true or publishConfig prevent an accidental release?files or ignore rules?-w, --workspace, or --workspaces?When helping with npm tasks, prefer guidance that: