0

When I try to create a new Angular 4 project with 'ng new myProject', the project folder, sub folders and files are created, but I also always get these errors:

npm ERR! path c:\projects\hello-world\node_modules\fsevents\node_modules
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall rmdir
npm ERR! Error: EPERM: operation not permitted, rmdir 'c:\projects\hello-world\node_modules\fsevents\node_modules'
npm ERR!  { Error: EPERM: operation not permitted, rmdir 'c:\projects\hello-world\node_modules\fsevents\node_modules'
npm ERR!   stack: 'Error: EPERM: operation not permitted, rmdir \'c:\\projects\\hello-world\\node_modules\\fsevents\\node_modules\'',
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'rmdir',
npm ERR! path: 'c:\\projects\\hello-world\\node_modules\\fsevents\\node_modules' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

I open the Node.js command prompt as Administrator when I issue the ng new command.

I am using Win7 Pro. I have install the following successfully and without any errors. The ng -v returns the following:

-Angular CLI: 1.5.0
-Node: 8.9.0
-OS: win32 x64
-Angular:

npm -v returns: 5.5.1

I give my user account, based on the 'whoami' results, full admin permissions to the myProject folder, the C:\Users\myAccount\AppData\Roaming\npm folder and %APPDATA%\npm-cache folder.

I also perform a 'npm cache verify'.

But I still get the above errors on the ng new command.

How do I correct these errors? Or can I ignore these errors?

Jerry
  • 6,357
  • 8
  • 35
  • 50
  • On windows when installing a lib that contains `fsevents`, it always shows a warning that fsevents does not work with windows (words to that effect). As I have no `node_modules/fsevents` in my projects, I'm wondering how it got into yours? – Richard Matsen Nov 07 '17 at 01:37
  • Perhaps a reboot? [Fail to install npm package “npm ERR! errno -4048”](https://stackoverflow.com/questions/30860795/fail-to-install-npm-package-npm-err-errno-4048) – Richard Matsen Nov 07 '17 at 01:42
  • I'm not sure but I think I used to get this error and fixed it by running my terminal as administrator. – Ploppy Nov 07 '17 at 01:59
  • I have rebooted and I do open Node.js command prompt as Administrator. But I still get the errors above when issue a 'ng new myProject' command. – Jerry Nov 07 '17 at 14:17

1 Answers1

1

If you still run into this problem, one reason you might be running into this is that you installed your CLI tools (@angular/cli) using either 'sudo npm install -g @angular/cli' or as root, from the 'sudo su - root' command, then simply 'npm install -g @angular/cli', and your problem seems to arise whenever you're not logged in and calling an 'ng' command as root or with 'sudo'. This makes sense, but it always causes some kind of insufficient permission related error; and it's not even your fault.

You can easily try to fix or mitigate this serious error by creating and saving a dot-file named '.npm-global' in your home directory ('~/'), then running the command, npm config set prefix '~/.npm-global'. Then, simply include the line in either /etc/profile or ~/.profile, export PATH=~/.npm-global/bin:$PATH, and run 'source /etc/profile' or 'source ~/.profile' to finalize it. [1]

After that, simply remove anything Node, like 'node_modules/', 'package-lock.json', just all of it.... Then, try installing your NPM packages again -- this time, without using 'sudo' and without root signed in.

  1. https://docs.npmjs.com/getting-started/fixing-npm-permissions
Levi Maes
  • 124
  • 2