0

I tried installing angular cli with npm. But I'm getting the below error while executing the command npm install -g @angular/cli. I am not executing this command as admin, but as a user.

D:\AngularWorkstation>npm install -g @angular/cli
npm WARN sass-loader@6.0.6 requires a peer of node-sass@^4.0.0 but none is installed. You must install peer dependencies yourself.

npm ERR! path **D:\node_modules\node_modules\@angular\cli\node_modules\which\package.json.365294863
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall rename
npm ERR! Error: EPERM: operation not permitted, rename 'D:\node_modules\node_modules\@angular\cli\node_modules\which\package.json.365294863' -> 'D:\node_modules\node_modules\@angular\cli\node_modules\which\package.json'
npm ERR!  { Error: EPERM: operation not permitted, rename 'D:\node_modules\node_modules\@angular\cli\node_modules\which\package.json.365294863' -> 'D:\node_modules\node_modules\@angular\cli\node_modules\which\package.json'
npm ERR!   cause:
npm ERR!    { Error: EPERM: operation not permitted, rename 'D:\node_modules\node_modules\@angular\cli\node_modules\which\package.json.365294863' ->** 'D:\node_modules\node_modules\@angular\cli\node_modules\which\package.json'
npm ERR!      errno: -4048,
npm ERR!      code: 'EPERM',
npm ERR!      syscall: 'rename',
npm ERR!      path: 'D:\\node_modules\\node_modules\\@angular\\cli\\node_modules\\which\\package.json.365294863',
npm ERR!      dest: 'D:\\node_modules\\node_modules\\@angular\\cli\\node_modules\\which\\package.json' },
npm ERR!   stack: 'Error: EPERM: operation not permitted, rename \'D:\\node_modules\\node_modules\\@angular\\cli\\node_modules\\which\\package.json.365294863\' -> \'D:\\node_modules\\node_modules\\@angular\\cli\\node_modules\\which\\package.json\'',
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'rename',
npm ERR!   path: 'D:\\node_modules\\node_modules\\@angular\\cli\\node_modules\\which\\package.json.365294863',
npm ERR!   dest: 'D:\\node_modules\\node_modules\\@angular\\cli\\node_modules\\which\\package.json',
npm ERR!   parent: '@angular/cli' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\techno\AppData\Roaming\npm-cache\_logs\2018-01-03T09_14_35_602Z-debug.log

*PS : I'm using Windows10 OS. I also tried changing the npm global path to'D:\node_modules' to check if it's due to permission issue. However the output is the same.

node --version : v7.7.2
npm --version : 4.1.2*
Elangovan
  • 3,469
  • 4
  • 31
  • 38
technoJ
  • 175
  • 1
  • 1
  • 16

3 Answers3

1

I had a similar issue when trying to install Yeoman with npm on Windows 10. The culprit turned out to be the McAfee AV software that was installed on my machine. McAfee seemed to be scanning the changes that npm was trying to make to a json file and as part of the scanning routine, prevented the rename from occurring. This resulted in a 4048 error being raised by npm similar to the error in your output.

To get around this I:

  1. Uninstalled McAfee and restarted my machine so that it reverted to Microsoft's built-in security software.
  2. Re-ran the npm install command and it worked correctly.

Alternatively, you could change the settings of your AV software to not actively check file changes for the node_modules folder. This would hopefully allow your AV software to stay installed and the npm command to work too.

Neil Russell
  • 91
  • 1
  • 3
0

From your error logs, It seems that there is some permission issue while installing the packages. You can specifically resolve this issue by two ways.

1) If you are trying to install the packages globally then you have to run the npm install <pkg_name> -g command with the administrative user or using sudo npm install <pkg_name> -g command.

To install the npm-packages globally you can follow the steps below:

  • Run the command prompt as the administrative user.
  • Run npm install <pkg_name> -g.

2) You should try going to the top-level folder in Windows Explorer, right-click on "get more info" option then go down to the permissions section, give yourself all permissions, and tell it to apply them recursively.

  • Or simply you can go to specified npm working directory and edit to permission section and allow all the permission to the current user and also change the owner to itself for all the recursive directories as well.

  • Then boot up Windows again.

Note: If you are installing an npm-package locally, then you should be in your local project directory and can try running sudo npm install <pkg-name> command to install required package. the purpose of using sudo is that it will change your owner permissions so you can make your current user authorized to run npm commands.

Suhas Gavad
  • 1,199
  • 1
  • 8
  • 12
0

1) uninstall node 2) download latest version of node from [https://nodejs.org/en/][1] . 3) install node js