Plot
A few days ago, I was trying to set up an angular project. The goal was simple, that was to install angular-cli with npm or yarn. Easy-peasy.
But, the bad omen struck. Angular is a careful, robust, feature-rich framework. When I say careful, it’s very specific in many ways. The command was simple: npm install -g @angular/cli
. Wanted to install angular globally, super simple, nothing crazy. Typically, it was supposed to be installed, but didn’t!
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/lib/node_modules/@angular
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/@angular'
npm ERR! [Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/@angular'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/usr/lib/node_modules/@angular'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in: /home/unknown/.npm/_logs/2023-12-20T04_33_49_897Z-debug-0.log
As you can see from the above error, I tried to figure out a few ways, such as using sudo
, changing paths, so on and so forth. I went on to the stack overflow (I still do visit the site 🥹) and checked some blogs, but nothing worked. Eventually, I found one of the longest GitHub discussions that I’ve ever seen, guess what, it didn’t work as well.
Actually, the solutions were pretty common, such as clear the cache, force install, change permissions, uninstall and reinstall, check for versions of node and some other clichés. Even ChatGPT gave somewhat similar answers.
Plot Twist
Not until I realized that my system had Emacs. So what, you may ask? It happens that Emacs has something called emacs-ng and its command was named as ng
on my system. Finally, I solved the problem by uninstalling that (ng-common), creating a separate path (.npm-global) and moved on with my life.