> Canonical URL: https://codingcat.dev/post/npm-tips-and-tricks

# NPM Tips and Tricks

✏️ Blog PostMay 17, 2019

# NPM Tips and Tricks

![](https://cdn.sanity.io/media-libraries/mlttp0BZbCpV/images/f0e7e772bc610f27a7269613b9bb01bb36f6b37f-1280x720.jpg?w=1920&h=1080&q=82&fit=max&auto=format)[![Alex Patterson](https://cdn.sanity.io/media-libraries/mlttp0BZbCpV/images/a606dfaa381aab08ddbe16a33fe1d3e1fb37c927-400x400.jpg?w=96&h=96&q=82&fit=max&auto=format)Alex Patterson](/author/alex-patterson)✏️ Visual Architecture Diagram

## how this post connects together.

Follow AJ from first principles to production-ready architecture.

Let’s build it!✏️ Visual Diagram: NPM Tips and Tricks✓ Good PatternVISUAL DIAGRAM[Diagram Walkthrough]Step-by-step diagram breakdown for NPM Tips and Tricks: start with NPM Tips and Tricks, implement Hands-On Implementation, and ship to production.AAA Contrast Verified

**NPM Tips and Tricks ** is a technical guide on CodingCat.dev by Alex Patterson focused on Node.js, DevOps, JavaScript. Adding NPM Globally, setting default values for packages, and stopping the dreaded sudo calls. NPM Tips and Tricks - Installing NodeJs - .npmrc config: 🎓 Lesson: https://ajonp.com/lessons/3-npm/ Ever wonder why you get EACCES without npm sudo? We can fix that and also provide other quick tips. ~~
Please note in order for you to run commands, you **must** update your .bash_profile
Then you can restart Terminal by either closing and restarting, or, In today's video, we'll be covering quick tips with NPM. After installing Node and NPM freshly, you'll typically try to install global package and get this EA access failure. We'll want to correct this. NPM comes with a nice configuration file called {dot} NPMRC that you can locate in your home folder. Currently, mine's empty. What we're going to do is add this line having a prefix home {dot} NPM... Watch the full video breakdown on [**YouTube**](https://www.youtube.com/watch?v=eWc0bg9KMQQ) or explore the architectural notes, chapters, and official documentation links below.

## NPM Global install fail

Ever get the dreaded EACCES error after running npm install -g? You're not alone!

You will notice that npm is trying to install its packages to this path:

Missing write access to /usr/local/lib/node_modules

We need to change this to a better path that you have the rights to upate.

## .npmrc update

using vim or nano update your local .npmrc file

`vim ~/.npmrc`

Update this file with the below, this will tell npm to install packages locally to .npm-packages

Copied! 🐾

```
prefix=${HOME}/.npm-packages
```

## NPM Global install success

Once you change the .npmrc file, you will begin to install packages to ~/.npm-packages. No more issues

![](https://cdn.sanity.io/media-libraries/mlttp0BZbCpV/images/4ed5b376e6b2c00a116a82dc258406e92f7af469-2020x318.jpg?w=1600&q=82&fit=max&auto=format)

# NPM init defaults

If you start projects using npm often enough you will want to default some of the authoring items. The basic syntax is `npm config set init.*`

> Don't stress out if you are updating using npm config set while in a different directory this will still update in ~/.npmrc

Copied! 🐾

```
npm config set init.author.name "Alex Patterson"
npm config set init.author.email "developer@ajonp.com"
npm config set init.author.url "https://ajonp.com/"
npm config set init.license "MIT"
npm config set init.version "0.0.1"
```

Now our full .npmrc will look like:

Copied! 🐾

```
prefix=/Users/ajonp/.npm-packages init.author.name=Alex Patterson init.author.email=developer@ajonp.com init.author.url=https://ajonp.com/ init.license=MIT init.version=0.0.1
```

Executing npm init will produce the following just by hitting enter.

Copied! 🐾

```
{
	"name": "npm-sample",
	"version": "0.0.1",
	"description": "Sample NPM",
	"main": "index.js",
	"scripts": {
		"test": "echo \"Error: no test specified\" && exit 1"
	},
	"author": "Alex Patterson  (https://ajonp.com/)",
	"license": "MIT"
}
```

# Setting NPM registry

At work we have a VSTS (aka Visual Studio aka DevOps) private npm registry so it becomes important to use `npm config set registry`

Copied! 🐾

```
https://.pkgs.visualstudio.com/_packaging//npm/registry/
```

Which will result in updating .npmrc with

Copied! 🐾

```
registry=https://.pkgs.visualstudio.com/_packaging//npm/registry/
```

There is a great [medium article](https://medium.com/@shemseddine/private-npm-package-deployment-using-vsts-92e19668f7d3) on setting up VSTS npm.

# Setting NPM loglevel

Probably my favorite setting of all is `npm config set loglevel="warn"`, this allows me to see any output and only the warnings. There are several different levels in the [npm docs](https://docs.npmjs.com/misc/config), you execute any of them by running something like below:

Copied! 🐾

```
npm i -g ionic -s --silent: --loglevel silent -q, --quiet: --loglevel warn -d: --loglevel info -dd, --verbose: --loglevel verbose -ddd: --loglevel silly
```

## Resources, Links & Official Documentation

- **Watch on YouTube: ** [NPM Tips and Tricks Full Video](https://www.youtube.com/watch?v=eWc0bg9KMQQ) (plus [Subscribe to CodingCat.dev](https://www.youtube.com/@CodingCatDev?sub_confirmation=1))
- **🎥 YouTube: ** [https://link.ajonp.com/youtube](https://link.ajonp.com/youtube)
- **🌎 Site: ** [https://link.ajonp.com/😺](https://link.ajonp.com/😺)
- **📦 GitHub: ** [https://link.ajonp.com/github](https://link.ajonp.com/github)
- **🎓Lessons: ** [https://link.ajonp.com/lessons](https://link.ajonp.com/lessons)
- **🗞AJ’s Week in Web: ** [https://link.ajonp.com/week-in-web](https://link.ajonp.com/week-in-web)
- **💬 Slack: ** [https://link.ajonp.com/slack](https://link.ajonp.com/slack)
- **🐦 Twitter: ** [https://link.ajonp.com/twitter](https://link.ajonp.com/twitter)
- **💬 Slack: ** [https://bit.ly/ajonp-slack-invite](https://bit.ly/ajonp-slack-invite)
- **🐦 Twitter: ** [https://bit.ly/ajonp-twitter](https://bit.ly/ajonp-twitter)
- [**Node.js API Reference:**](https://nodejs.org/docs/latest/api/) Event loop, streams, native fetch, and server-side JavaScript
- [**GitHub Actions CI/CD Documentation:**](https://docs.github.com/en/actions) Automated deployment pipelines, secrets management, and runners
- [**MDN JavaScript Reference:**](https://developer.mozilla.org/en-US/docs/Web/JavaScript) ECMAScript specifications, Web APIs, and runtime fundamentals

## Related CodingCat.dev Tutorials & Podcast Episodes

- [**Speedrun Your App Onto Fly.io**](/podcast/3-22-fly-io-with-dov-alperin): Fly is a platform for running full stack apps and databases close to your users
- [**How to add Sentry to Next.js the right way!**](/podcast/how-to-add-sentry-to-next-js-the-right-way): Discover how to set up Sentry with Next.js for seamless error monitoring and performance tracking.
- [**Supabase New Release**](/podcast/4-6-supabase-release-week-x-new-features): Supabase dropped a lot of new features during their X launch, I review these with Jon.

## Frequently Asked Questions (FAQ)

### What are the main takeaways from NPM Tips and Tricks?

Adding NPM Globally, setting default values for packages, and stopping the dreaded sudo calls. NPM Tips and Tricks - Installing NodeJs - .npmrc config: 🎓 Lesson: https://ajonp.com/lessons/3-npm/ Ever wonder why you get EACCES without npm sudo? We can fix that and also provide other quick tips. ~~
Please note in order for you to run commands, you **must** update your .bash_profile
Then you can restart Terminal by either closing and restarting, or, In today's video, we'll be covering quick tips with NPM. After installing Node and NPM freshly, you'll typically try to install global package and get this EA access failure. We'll want to correct this. NPM comes with a nice configuration file called {dot} NPMRC that you can locate in your home folder. Currently, mine's empty. What we're going to do is add this line having a prefix home {dot} NPM... Throughout this post, Alex Patterson breaks down real-world implementation details for Node.js, DevOps, JavaScript so developers can apply these patterns directly in production.

### How do you implement Node.js best practices in production?

When adopting Node.js and DevOps in a production stack, start by validating your configuration against the [**Node.js API Reference**](https://nodejs.org/docs/latest/api/) (Event loop, streams, native fetch, and server-side JavaScript). Focus on incremental adoption, automated testing, and observability so your team can measure performance and developer velocity improvements at each stage.

### Where can I watch the full NPM Tips and Tricks walkthrough and find related code resources?

You can watch the complete video session for [**NPM Tips and Tricks**](https://www.youtube.com/watch?v=eWc0bg9KMQQ) on the [**CodingCat.dev YouTube channel**](https://www.youtube.com/@CodingCatDev?sub_confirmation=1). For a deeper dive into Node.js, check out our related guide: [**Speedrun Your App Onto Fly.io**](/podcast/3-22-fly-io-with-dov-alperin).

## ✏️ Video Summary

NPM Tips and Tricks - Installing NodeJs - .npmrc config: 🎓 Lesson: https://ajonp.com/lessons/3-npm/

Ever wonder why you get EACCES without npm sudo? We can fix that and also provide other quick tips.

~~
Please note in order for you to run commands, you **must** update your .bash_profile
Then you can restart Terminal by either closing and restarting, or — In today's video, we'll be covering quick tips with NPM. After installing Node and NPM freshly, you'll typically try to install global package and get this EA access failure. We'll want to correct this. NPM comes with a nice configuration file called {dot} NPMRC that you can locate in your home folder. Currently, mine's empty. What we're going to do is add this line having a prefix home {dot} NPM...

## recent blog posts.

[All Blog Posts&rarr;](/blog)[![The Heads of AI wearing black company logo t-shirts and shaking hands in a circular web of cloud and GPU investments](https://cdn.sanity.io/media-libraries/mlttp0BZbCpV/images/d1d83d596ce5899d797cd3aaf1bd0142038f282a-1376x768.jpg?w=1376&q=82&fit=max&auto=format)](/post/anthropic-s1-ipo-circular-ai-economy-etf-risk)October 26, 2026[![](/logos/amplify/amplify.svg)![](/logos/amplify/amplify.svg)AWS Amplify](/topic/amplify)[AI & MCP Agents](/topic/ai)

### [Anthropic's S-1, $518B in cloud commitments, and circular AI capex](/post/anthropic-s1-ipo-circular-ai-economy-etf-risk)

Anthropic just filed its Form S-1 for a Nasdaq IPO under ticker ANT, revealing $518B in take-or-pay cloud commitments to Google, AWS, and Microsoft. Here is how Mark Zuckerberg, Elon Musk, Jensen Huang, Sundar Pichai, Satya Nadella, Tim Cook, and Dario Amodei built a circular revenue machine, and what happens to your S&P 500 ETF if it stalls.

[![Alex Patterson](https://cdn.sanity.io/media-libraries/mlttp0BZbCpV/images/a606dfaa381aab08ddbe16a33fe1d3e1fb37c927-400x400.jpg?w=96&h=96&q=82&fit=max&auto=format)Alex Patterson](/author/alex-patterson)[![PHP2Shell (CVE-2026-109618): How AI Found a Decade-Old Bug in 70% of the Web](https://cdn.sanity.io/media-libraries/mlttp0BZbCpV/images/e83065d0a4e2f841ce64d3f4aea8ddbbf07e5cb9-1376x768.jpg?w=1376&q=82&fit=max&auto=format)](/post/php2shell-cve-2026-109618-ai-php-security-scramble)October 22, 2026[![](/logos/amplify/amplify.svg)![](/logos/amplify/amplify.svg)AWS Amplify](/topic/amplify)[AI & MCP Agents](/topic/ai)

### [PHP2Shell (CVE-2026-109618): How AI Found a Decade-Old Bug in 70% of the Web](/post/php2shell-cve-2026-109618-ai-php-security-scramble)

Two critical pre-authentication RCE flaws in PHP (CVE-2026-109618 and CVE-2026-109619), uncovered by AI models from OpenAI and Google Gemini, sparked a global patching scramble across 70% of the web. Here is how PHP2Shell works and how to patch your servers.

[![Alex Patterson](https://cdn.sanity.io/media-libraries/mlttp0BZbCpV/images/a606dfaa381aab08ddbe16a33fe1d3e1fb37c927-400x400.jpg?w=96&h=96&q=82&fit=max&auto=format)Alex Patterson](/author/alex-patterson)