uninstall
Remove packages from npm projects to manage dependencies and reduce project size. Specify package names and project path to uninstall them locally or globally.
Instructions
Remove packages from a project
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Absolute path to the package directory | |
| packages | Yes | Package names to uninstall | |
| global | No | Uninstall from global |
Implementation Reference
- src/index.ts:435-457 (handler)The "uninstall" tool is registered and implemented in src/index.ts. It calls the 'run' helper function with the appropriate 'npm uninstall' arguments.
// ── npm uninstall ── server.tool( "uninstall", "Remove packages from a project", { path: z.string().describe("Absolute path to the package directory"), packages: z.array(z.string()).describe("Package names to uninstall"), global: z.boolean().optional().describe("Uninstall from global"), }, async ({ path, packages, global: isGlobal }) => { const args = ["uninstall", ...packages]; if (isGlobal) args.push("-g"); try { const { stdout, stderr } = await run(args, path); return { content: [{ type: "text", text: stdout + stderr }] }; } catch (e: any) { return { content: [{ type: "text", text: `Error: ${e.stderr || e.message}` }], isError: true, }; } }, );