installing PhantomJS on Windows: rolling back Error: EPERM, unlink phantomjs.exe

I try to install karam/Jasmine/PhantomJS on my Windows machine.

It was installed before in a different project. I have my proxies set up nicely, but it throws a weird error.

npm ERR! error rolling back Error: EPERM, unlink 'C:\xampp\htdocs\acme\node_modules\karma-phantomjs-launcher\node_modules\phantomjs\lib\phantom\phantomjs.exe'
npm ERR! error rolling back  karma-phantomjs-launcher@0.1.4 { [Error: EPERM, unlink 'C:\xampp\htdocs\acme\node_modules\karma-phantomjs-launcher\node_modules\phantomjs\lib\phantom\phantomjs.exe']
npm ERR! error rolling back   errno: 50,
npm ERR! error rolling back   code: 'EPERM',
npm ERR! error rolling back   path: 'C:\\xampp\\htdocs\\acme\\node_modules\\karma-phantomjs-launcher\\node_modules\\phantomjs\\lib\\phantom\\phantomjs.exe' }
npm ERR! Error: EPERM, unlink 'C:\xampp\htdocs\acme\node_modules\karma-phantomjs-launcher\node_modules\phantomjs\lib\phantom\phantomjs.exe'
npm ERR!  { [Error: EPERM, unlink 'C:\xampp\htdocs\acme\node_modules\karma-phantomjs-launcher\node_modules\phantomjs\lib\phantom\phantomjs.exe']
npm ERR!   errno: 50,
npm ERR!   code: 'EPERM',
npm ERR!   path: 'C:\\xampp\\htdocs\\acme\\node_modules\\karma-phantomjs-launcher\\node_modules\\phantomjs\\lib\\phantom\\phantomjs.exe' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
  • So I deleted the phantomjs.exe and tried again.
  • I executed the console as admin and retried.
  • I deleted the whole node_modules folder and installed again
  • I used npm cache clear
  • I deactivated my A/V as suggested here

... same error.

Why would npm try to delete the PhantomJS during install? As I said, I deleted it before. So I have no node_modules folder, execute npm install and it creates the phantomjs.exe and then fails with said error.

Any ideas anyone?

I had a similar issue that ultimately seemed to have been caused by still having an errant phantomjs.exe process running while I was performing an npm update.

While it seems unlikely that this may have been the same cause as what you were experiencing, it seems to be at the very least one of the ways to receive this same error message.

I was able to resolve by opening up Windows Task Manager (Ctrl+Shift+Esc), finding phantomjs.exe in the Processes tab, and using 'End Process' on it.