npm
π―SkillInstallation
npx skills add g1joshi/agent-skills --skill npmRun it in a terminal; it asks which AI coding tools to install it for (Claude Code, Codex, Cursor and more).
Uses skills.sh Β· Node.js 22.20+
After installing
Ask for related work and the agent uses it on its own, or call it yourself.
/npmInstall by hand
Copy the whole skill folder from GitHub to the place below. Copying only SKILL.md can leave out files the skill uses.
Open the skill folder β- This project
.claude/skills/npm/ - All projects
~/.claude/skills/npm/
These paths are for Claude Code. For other tools, the command above puts it in the right place.
SKILL.md
View on GitHub βExpert npm package manager assistance covering package.json, lockfiles, workspaces (monorepos), scripts, and security audits. Use when managing JavaScript/Node.js dependencies and publishing packages.
npm
npm is the default package manager for Node.js, providing dependency resolution, workspace management, security auditing, and publishing workflows for JavaScript ecosystems.
When to Use
- JavaScript / TypeScript Package Management: Installing, publishing, and managing npm modules and dependencies.
- Multi-Package Monorepos (npm Workspaces): Coordinating interconnected local packages with unified dependency resolution.
- Supply Chain Security & Provenance: Publishing packages with cryptographically verifiable build provenance.
- Vulnerability Auditing & Dependency Overrides: Resolving transitively vulnerable packages using
overrides.
Quick Start
npm init -y
npm install lodash
npm install --save-dev jest
# Monorepo
npm init -w packages/my-lib
Core Concepts
Configuring npm Workspaces in Monorepos
Declaring multi-package structures in root package.json:
{
"name": "enterprise-monorepo",
"private": true,
"workspaces": ["packages/*", "apps/*"],
"scripts": {
"build": "npm run build --workspaces --if-present",
"test": "npm test --workspaces --if-present"
},
"overrides": {
"glob": "^10.4.0",
"semver": "^7.6.0"
}
}
Clean Installations & Deterministic Lockfiles
Installing dependencies in continuous integration:
# Clean install adhering strictly to package-lock.json (never mutates lockfile)
npm ci
# Audit dependencies for known CVEs
npm audit --audit-level=high
# Run targeted script across all workspaces
npm run test --workspace=packages/core-utils
Publishing Packages with Cryptographic Provenance
Publishing to the npm registry with supply-chain verification:
# Publish package with Sigstore verifiable provenance
npm publish --access public --provenance
Common Patterns
Monorepo Workspaces Configuration
Problem: Managing shared libraries across multiple internal packages without publishing to external registries.
Solution:
Use native npm workspaces in root package.json:
{
"name": "my-monorepo",
"private": true,
"workspaces": ["packages/*", "apps/*"],
"scripts": {
"build": "npm run build --workspaces --if-present",
"test": "npm test --workspaces"
}
}
Best Practices
Do:
- Always use
npm ciin CI/CD pipelines instead ofnpm installto enforce exact lockfile dependencies. - Publish public packages with
--provenanceto establish cryptographic build transparency. - Use
overridesin rootpackage.jsonto resolve security vulnerabilities in deep transitive dependencies. - Commit
package-lock.jsonto version control in all projects.
Don't:
- Use
npm install --forceor--legacy-peer-depsin production builds; resolve peer version conflicts cleanly. - Publish packages containing sensitive files; maintain an explicit
.npmignoreor"files"whitelist. - Execute untrusted scripts during install without verifying packages (
npm install --ignore-scripts).
Troubleshooting
| Error | Cause | Solution |
|---|---|---|
npm ERR! code ERESOLVE: could not resolve dependency | Peer dependency version conflict. | Run npm install --legacy-peer-deps or align conflicting package versions. |
npm ERR! code EACCES: permission denied | Installing global packages without permissions on system node directory. | Configure user npm prefix: npm config set prefix ~/.npm-global. |
package-lock.json out of sync | Dependencies installed with different npm major versions. | Delete node_modules and run npm ci for strict deterministic installs. |
References
More from this repository10
A template skill providing a starter framework for creating new agent skills with structured sections for triggers, quick start examples, and capability descriptions.
Skill
Skill
Skill
Skill
Skill
Skill
Skill
Skill
Skill