DEV Community

Poopcoder
Poopcoder

Posted on • Originally published at poopcode.com on

15 1

Remove unused npm modules from package.json

Depcheck is a tool for analyzing the dependencies in a project to see: how each dependency is used, which dependencies are useless, and which dependencies are unused from package.json. To identify the unused package, just run npx depcheck in the project root directory.

> npx depcheck


npx: installed 146 in 88.761s
Unused dependencies
* express-validator
Enter fullscreen mode Exit fullscreen mode

Next step is to uninstall the npm packages using npm uninstall command.

npm uninstall express-validator
npm WARN retina-backend@1.0.0 No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.2 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

removed 2 packages and audited 626 packages in 12.337s

24 packages are looking for funding
  run `npm fund` for details

found 24150 vulnerabilities (24147 low, 3 high)
  run `npm audit fix` to fix them, or `npm audit` for details
Enter fullscreen mode Exit fullscreen mode

The post Remove unused npm modules from package.json appeared first on Poopcode.

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (3)

Collapse
 
batbrain9392 profile image
Debmallya Bhattacharya

It's not really 100% accurate. Firstly, it lists all devDependencies as unused. Secondly, it listed @nrwl/angular and tslib as unused in an Nx+Angular project, both of which are required.

Collapse
 
angelalexqc profile image
Ángel Quiroz • Edited

Exactly, is like build process deps resolutions, the tool works for me for solve a deps conflict with husky and older versions of redux-devtools, my point its this tools works in many use cases.
👍🏻

Collapse
 
guhkun13 profile image
name cannot be blank • Edited

so i created this script to remove ALL UNUSED deps, (works in unix): dev.to/guhkun13/comment/1eak1

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

If this article connected with you, consider tapping ❤️ or leaving a brief comment to share your thoughts!

Okay