Trevor Recommends
Codecrafters logo
I've been using Codecrafters to level up my coding skills by building Redis, Shell, Git, Kafka, SQLite from scratch. It's free to start and really helped me understand the internals. 40% off if you want the full experience.
Up to date
Published
2 min read

Trevor I. Lasn

Staff Software Engineer, Engineering Manager

NPQ: Open source CLI tool that audits and protects your npm installs from malicious packages

A CLI tool that checks packages for security issues and social engineering attacks before they hit your project

I stumbled across the NPQ CLI tool while browsing GitHub, and it addresses something that’s been bugging me for years. Every time you run npm install, you’re basically trusting random strangers on the internet not to mess with your computer.

NPQ sits between you and npm, checking packages for sketchy behavior before they touch your project. Here’s the general idea:

Terminal window
npm install -g npq
npq install next
Packages with issues found:
┌─
> next@latest
Supply Chain Security · Detected a recently published version (published 2 days ago) - consider waiting for community review
└─
Summary:
- Total packages: 1
- Total errors: 1
- Total warnings: 0
Continue install ? (y/N) n

Why Audit Your Packages?

Here’s what happens when you install a package. You type npm install package and suddenly you’ve downloaded code from someone you’ve never met. That code runs on your machine with your permissions. It can read files, make network requests, and do whatever it wants.

Most packages are fine. But some aren’t. Maybe they’re typosquatting popular libraries. Maybe they’re trying to steal your environment variables. Maybe they’re just poorly maintained and full of vulnerabilities.

You probably don’t check every package manually. Who has time for that?

NPQ acts like a bouncer for your npm installs. When you try to install something, it checks a bunch of things first:

[1] The package name looks legitimate and isn’t trying to impersonate something popular.

[2] The maintainer has a reasonable history and isn’t brand new with no other packages.

[3] The package doesn’t have obvious red flags like requesting unnecessary permissions or making suspicious network calls.

If something looks wrong, NPQ blocks the install and tells you why. If everything checks out, your install proceeds normally.

Since npq is a pre-step to ensure that the npm package you’re installing is safe, you can safely embed it in your day-to-day npm usage so there’s no need to remember to run npq explicitly.

Terminal window
alias npm='npq-hero'

Found this article helpful? You might enjoy my free newsletter. I share dev tips and insights to help you grow your coding skills and advance your tech career.

Interested in supporting this blog in exchange for a shoutout? Get in touch.


Liked this post?

Check out these related articles that might be useful for you. They cover similar topics and provide additional insights.

Webdev
3 min read

align-content: The Simplest Way to Center Content with CSS

Finally, we can center things in block layouts without flexbox gymnastics

Dec 13, 2024
Read article
Webdev
12 min read

Frontend Security Checklist

Tips for Keeping All Frontend Applications Secure

Jul 30, 2024
Read article
Webdev
3 min read

Native Popover Element with HTML

Create overlays and dropdowns easily with the native HTML popover API

Jan 24, 2025
Read article
Webdev
3 min read

CSS Supports Nesting Now

CSS nesting is finally supported in all major browsers. Write cleaner, organized stylesheets without Sass or Less

Dec 6, 2024
Read article
Webdev
4 min read

How To Implement Content Security Policy (CSP) Headers For Astro

Content Security Policy (CSP) acts like a shield against XSS attacks. These attacks are sneaky - they trick your browser into running malicious code by hiding it in content that seems trustworthy. CSP's job is to spot these tricks and shut them down, while also alerting you to any attempts it detects.

Oct 16, 2024
Read article
Webdev
4 min read

Open Dyslexic Font: Improve Your Web Accessibility

How to implement the Open-Dyslexic font to enhance readability for users with dyslexia

Oct 12, 2024
Read article
Webdev
4 min read

Speed Up Your Website With rel='preconnect' and increase PageSpeed Insights Score

Using link rel='preconnect' can improve your website's performance by reducing connection setup times to key external domains.

Sep 13, 2024
Read article
Webdev
3 min read

scrollbar-width & scrollbar-gutter: CSS Properties for Layout Control

Prevent content shifts and refine scrollable UIs with scrollbar-width and scrollbar-gutter

Dec 19, 2024
Read article
Webdev
3 min read

CVE-2025-29927 - Next.js Middleware Bypass Explained In Simple Terms

The vulnerability skips Next.js middleware security checks by adding a single HTTP header

Apr 6, 2025
Read article

This article was originally published on https://www.trevorlasn.com/blog/npq-protects-npm-installs-from-malicious-packages. It was written by a human and polished using grammar tools for clarity.