Cannot create a new project

I am facing this issue. What should I do?

Hi @divyansh45! There is an open issue with installing global packages using sudo leaving behind files with the wrong ownership.

The short version is run this to fix the ownership, then try your command again (assuming bash shell):


sudo chown -R $(whoami) ~/.npm

The long version and canonical bug is: Global installs (sudo npm i -g) fail on Mac after 6.5 upgrade. Works fine after 6.4.1 downgrade.

Hi @shadowspawn! I just used the command sudo ng new hello-world and I am facing this issue.

I have install it globally, all I am doing is I’m trying to create a project!

Possibly a bad cache or proxy issue, but you are going to have more problems anyway. I think you should not use sudo when creating a new project using ng. All the new files and folders will be owned by root rather than you, so you may now have the same ownership issue that was affecting that “.npm” folder but now affecting your whole project. e.g. you may not be able to save file changes in editor

Recommended best practice is to avoid using sudo at all, but that requires some setup if you have global packages. So second-best practice is only use sudo when working with global packages, and don’t use global packages when you could equally well use a local package.

I suggest making another new project without using sudo. It may fail same way, but I will be more confident we are working on the right problem! :-)