Recently, while trying to install TypeScript globally on my system using npm, I ran into a common but frustrating error:
npm install -g typescript
And boom — I got hit with this:
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/typescript
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/typescript'
This error means that npm doesn't have permission to create directories in the system's global modules folder (/usr/local/lib/node_modules/). This is a pretty common issue on macOS and Linux systems when trying to install global npm packages without sufficient privileges.
Understanding the Problem
EACCES stands for Error: Access Denied. When you see this error during a global installation, it usually means one of two things:
You're trying to write to a system directory that requires admin privileges.
Your npm configuration is pointing to a directory that you don't have access to.
Solution : Use sudo (Quick Fix)
If you trust the package and you just want it to work right now, run:
sudo npm install -g typescript
Top comments (0)