I'm using a Mac computer which is currently running macOS Ventura 13.1
I successfully installed node (v18.12.1) & npm (8.19.2) on the computer but when I try to run npm install -g @angular/cli
to install Angular CLI, it gave me the following error.
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/@angular
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/@angular'
npm ERR! [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/@angular'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/usr/local/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.
Also, I tried the command with sudo
, like sudo npm install -g @angular/cli
, and then it gave me the following error.
npm WARN deprecated @npmcli/[email protected]: This functionality has been moved to @npmcli/fs
npm WARN deprecated [email protected]: Please use @jridgewell/sourcemap-codec instead
I tried installing Angular CLI using homebrew
and nvm
, but neither of them succeeded.
Finally, I could solve the issue. Here's what I did,
I used homebrew to install Angular CLI via
brew install angular-cli
. Then when I checkng version
, it showed my current node version (v19) doesn't support for Angular. Then I used Node Version Manager (NVM) to downgrade my node version. I used the below command to install NVM on my Mac (macOS Ventura 13.1).This command automatically updated my
.zshrc
file as well. If it doesn't automatically updated for you, open the.zshrc
file usingopen -t .zshrc
command and add the following code to it.You can check nvm version using
nvm -v
command. After that I rannvm install 18.12.1
command to downgrade the node version to18.12.1
.You can run
node -v
command to verify.Then I ran
ng version
command and got the following output.Then I created my first angular app using
ng new my_first_app
command. It gave me the following error.Then I navigated to the project directory and I couldn't see both
node_modules
directory andpackage-lock.json
file. Then I tried running theng serve
command and it gave me an error and asked me to runnpm install
command. When I runnpm install
command, it didn't work successfully and still I couldn't seenode_modules
directory andpackage-lock.json
file inside the angular project.Finally, I ran the
npm install --legacy-peer-deps
command and it wasn't successful either. Then I ransudo npm install --legacy-peer-deps
command and finally it solved the problem.Then I ran the
ng serve
command and I could get it compiled successfully and see the output on the browser.Hope this answer will help you when you try to install Angular CLI on macOS Ventura 13.1