angular-cli: Install fails on Windows 7

OS: Windows 7

Node/NPM Version (Install failed. Can’t run ng):

node -v
v6.3.0 

npm -v
3.10.6

NOTE: Node version doesn’t matter. Tested on 4.4.7 as well. No change.

Reproduction Steps:

Run npm install -g angular-cli on Windows 7

Log:

npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Kyle\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\n
pm-cli.js" "install" "-g" "angular-cli"
npm ERR! node v6.3.0
npm ERR! npm  v3.10.6
npm ERR! path C:\Users\Kyle\AppData\Roaming\npm\node_modules\.angular-cli.DELETE\node_modules\traceur
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall rename

npm ERR! Error: EPERM: operation not permitted, rename 'C:\Users\Kyle\AppData\Roaming\npm\node_modules\.angular-cli.DE
LETE\node_modules\traceur' -> 'C:\Users\Kyle\AppData\Roaming\npm\node_modules\angular-cli\node_modules\traceur'
npm ERR!     at C:\Users\Kyle\AppData\Roaming\npm\node_modules\npm\lib\install\action\finalize.js:64:7
npm ERR!     at C:\Users\Kyle\AppData\Roaming\npm\node_modules\npm\node_modules\slide\lib\async-map.js:52:35
npm ERR!     at Array.forEach (native)
npm ERR!     at C:\Users\Kyle\AppData\Roaming\npm\node_modules\npm\node_modules\slide\lib\async-map.js:52:11
npm ERR!     at Array.forEach (native)
npm ERR!     at asyncMap (C:\Users\Kyle\AppData\Roaming\npm\node_modules\npm\node_modules\slide\lib\async-map.js:51:8)

npm ERR!     at moveModules (C:\Users\Kyle\AppData\Roaming\npm\node_modules\npm\lib\install\action\finalize.js:61:5)
npm ERR!     at C:\Users\Kyle\AppData\Roaming\npm\node_modules\npm\lib\install\action\finalize.js:56:70
npm ERR!     at C:\Users\Kyle\AppData\Roaming\npm\node_modules\npm\node_modules\mkdirp\index.js:30:20
npm ERR!     at FSReqWrap.oncomplete (fs.js:123:15)
npm ERR!
npm ERR! Error: EPERM: operation not permitted, rename 'C:\Users\Kyle\AppData\Roaming\npm\node_modules\.angular-cli.DE
LETE\node_modules\traceur' -> 'C:\Users\Kyle\AppData\Roaming\npm\node_modules\angular-cli\node_modules\traceur'
npm ERR!     at Error (native)
npm ERR!  Error: EPERM: operation not permitted, rename 'C:\Users\Kyle\AppData\Roaming\npm\node_modules\.angular-cli.D
ELETE\node_modules\traceur' -> 'C:\Users\Kyle\AppData\Roaming\npm\node_modules\angular-cli\node_modules\traceur'
npm ERR!     at C:\Users\Kyle\AppData\Roaming\npm\node_modules\npm\lib\install\action\finalize.js:64:7
npm ERR!     at C:\Users\Kyle\AppData\Roaming\npm\node_modules\npm\node_modules\slide\lib\async-map.js:52:35
npm ERR!     at Array.forEach (native)
npm ERR!     at C:\Users\Kyle\AppData\Roaming\npm\node_modules\npm\node_modules\slide\lib\async-map.js:52:11
npm ERR!     at Array.forEach (native)
npm ERR!     at asyncMap (C:\Users\Kyle\AppData\Roaming\npm\node_modules\npm\node_modules\slide\lib\async-map.js:51:8)

npm ERR!     at moveModules (C:\Users\Kyle\AppData\Roaming\npm\node_modules\npm\lib\install\action\finalize.js:61:5)
npm ERR!     at C:\Users\Kyle\AppData\Roaming\npm\node_modules\npm\lib\install\action\finalize.js:56:70
npm ERR!     at C:\Users\Kyle\AppData\Roaming\npm\node_modules\npm\node_modules\mkdirp\index.js:30:20
npm ERR!     at FSReqWrap.oncomplete (fs.js:123:15)
npm ERR!
npm ERR! Error: EPERM: operation not permitted, rename 'C:\Users\Kyle\AppData\Roaming\npm\node_modules\.angular-cli.DE
LETE\node_modules\traceur' -> 'C:\Users\Kyle\AppData\Roaming\npm\node_modules\angular-cli\node_modules\traceur'
npm ERR!     at Error (native)
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\Kyle\npm-debug.log
npm ERR! code 1

NOTES:

  1. Running as an administrator DOES NOT change anything. This includes if I EXPLICITY run cmd.exe as admin. It should not matter, but I tested it regardless…

  2. I’ve already searched high and low for a solution. I saw some info that related to ember-cli, but any of the proposed solutions do not apply. For example, there was some info about missing a permission to create symlinks. Does not apply in my case; I have the permission.

  3. I have typings installed globally already.

I can test this later on my personal computer (this is a corporate computer), but I don’t feel it will do much good (that machine is running Windows 10).

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 29 (7 by maintainers)

Most upvoted comments

I had the same problem with Win7 angular-cli installs.

It seems that Uninstalling node.js leaves an “npm” folder in the C:\Users<USERNAME>\AppData\Roaming directory. I deleted this folder, uninstalled and re-installed node.js, then angular-cli installed just fine.

It might be because you are running ng serve command somewhere in another terminal?

I got the similar error while I was running ng serve and at the same time trying to run npm install bootstrap@next (on my Windows 10 laptop).

Still experiencing this issue and none of the above solutions have worked, anyone have any other ideas?

Ran npm clean cache and re-ran npm install -g angular-cli. No change.

Tested on my Win10 machine last night. Install ran without any errors.

  1. Run command prompt as Administrator.
  2. Ran npm clean cache. After run this command and return Error than run . ( npm cache clean --force )
  3. npm install -g angular-cli

Same error happens to me. If you want to just forget about the root cause and resolve it right away like me…what I did was to modify the rename script used by the npm installation process (in finalize.js):

“nodejs installation folder”\node_modules\npm\lib\utils\rename.js

function rename (from, to, cb) {
  var saved = new SaveStack(rename)
  fs.rename(from, to, function (er) {
    if (er) {
	  console.log("rename error: " + from + " -> " + to);
	  // you have 30 seconds to rename the folder manually
          // remember to rename it to .angular-cli.DELETE (don't forget the period)
          setTimeout(cb, 30 * 1000) 
          //return cb(saved.completeWith(er))
    } else {
      return cb()
    }
  })
}

I know this is not ideal but works for me. Don’t forget to change the script back to it’s original version after that.

Closing all visual studio and SQL Management studio windows along with npm cache clear did the trick for me

The issue: C:\Users\<username>\AppData\Roaming\npm\node_modules\.angular-cli.DELETE

Solution: Open windows explorer and navigate to: C:\Users\<username>\AppData\Roaming\npm\node_modules\ Then delete folder named: .angular-cli.DELETE Optional, but suggested: npm clear cache Then run: npm install -g angular-cli

Note: .folder names are hidden by default. Show these files on Windows 7: http://www.bleepingcomputer.com/tutorials/show-hidden-files-in-windows-7/

@Radhakanta you know that once you delete that folder you won’t be able to use npm anymore, right? If yes, why are you sharing this? Don’t share your ignorancy please.

C:\Users\primeiro.ultimo\AppData\Roaming\npm>npm i @angular/cli -g module.js:471 throw err; ^

Error: Cannot find module ‘C:\Users\primeiro.ultimo\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js’ at Function.Module._resolveFilename (module.js:469:15) at Function.Module._load (module.js:417:25) at Module.runMain (module.js:604:10) at run (bootstrap_node.js:389:7) at startup (bootstrap_node.js:149:9) at bootstrap_node.js:504:3

I resolved it closing a running instance of ng serve.

@iamtracy that used to work for me in a few random cases when I had this happen. Not anymore.

Recently on Friday September 30 I was able to download angular-cli beta-16 globally in the morning (Sydney time), then during noon I was not able to upgrade to it from existing app using the CLI. Another friend was trying to install it globally but it failed too.

We both tried ensuring deleting the from and to names in the rename error, and clearing NPM cache, no luck.

Since these were corporate laptops (different models, running Windows 8.1, with admin access), I suspect that some antivirus update or so ran after I installed the CLI successfully for the last time. That’s an antivirus I cannot disable unfortunately.

Now I cannot re-install the same version of the CLI that worked before, and it’s failing consistently with the .DELETE error (although not always on the same folder). The usual tips (deleting folders, clearing npm cache, even uninstalling node -in this case 4.4.2 on one machine and 4.6 on another-, and also running npm install with --no-optional) all do not help.

I’m suspecting it’s https://github.com/npm/npm/issues/12059 as @filipesilva said, and consider trying https://github.com/npm/npm/issues/12059#issuecomment-232180291 tomorrow at work, but we only see it in the CLI, which may be because the amount of depedencnies the CLI requires is huge and amplifies the exisiting npm problem by several magnititudes.

As an update, I’ve found similar reports that indicate this might be a windows specific NPM issue: https://github.com/npm/npm/issues/12059 https://github.com/npm/npm/issues/10826