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
.zshrcfile as well. If it doesn't automatically updated for you, open the.zshrcfile usingopen -t .zshrccommand and add the following code to it.You can check nvm version using
nvm -vcommand. After that I rannvm install 18.12.1command to downgrade the node version to18.12.1.You can run
node -vcommand to verify.Then I ran
ng versioncommand and got the following output.Then I created my first angular app using
ng new my_first_appcommand. It gave me the following error.Then I navigated to the project directory and I couldn't see both
node_modulesdirectory andpackage-lock.jsonfile. Then I tried running theng servecommand and it gave me an error and asked me to runnpm installcommand. When I runnpm installcommand, it didn't work successfully and still I couldn't seenode_modulesdirectory andpackage-lock.jsonfile inside the angular project.Finally, I ran the
npm install --legacy-peer-depscommand and it wasn't successful either. Then I ransudo npm install --legacy-peer-depscommand and finally it solved the problem.Then I ran the
ng servecommand 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