Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed at the [email protected] install script 'node install.js'

I am trying to install phantomjs on a windows 7 machine and am getting this error .

npm ERR! Windows_NT 6.1.7601  
npm ERR! argv "C:\\Program Files (x86)\\nodist\\v\\nodev5.5.0\\node.exe"   "C:\\Program Files (x86)\\nodist\\bin\\node_mod  
ules\\npm\\bin\\npm-cli.js" "install"  
npm ERR! node v5.5.0  
npm ERR! npm  v3.10.9  
npm ERR! code ELIFECYCLE  

npm ERR! [email protected] install: `node install.js`  
npm ERR! Exit status 1  
npm ERR!  
npm ERR! Failed at the [email protected] install script 'node   install.js'.  
npm ERR! Make sure you have the latest version of node.js and npm installed.

There are many issues logged in the phantomjs github repo for the same or this SO questionbut none of it is helping in my case.

This is what is the state of my machine

  • I have phantomjs installed locally at C:\npm\phantomjs-2.1.1-windows\bin\phantomjs.exe but when I run the npm install,it will always try to install by downloading which is where the problem for me.My corporate proxy is blocking the direct downloads .I also cannot use the --phantomjs_cdnurl switch mentioned here https://www.npmjs.com/package/phantomjs#deciding-where-to-get-phantomjs
  • I can run the command and it works fine phantomjs -v
    2.1.1

But when I run npm install on my project it is trying to install the phantomjs and will run into the above error.Another thing I observed from the npm log

Considering PhantomJS found at C:\Program Files (x86)\nodist\bin\phantomjs.CMD Found PhantomJS at C:\Program Files (x86)\nodist\bin\phantomjs.CMD ...verifying Error verifying phantomjs, continuing { [Error: Command failed: C:\Program Files (x86)\nodist\bin\phantomjs.CMD --version

it is trying to run the phantomjs.CMD --version which also failing

Error verifying phantomjs, continuing { [Error: Command failed: C:\Program Files (x86)\nodist\bin\phantomjs.CMD --versio
n
internal/child_process.js:274
  var err = this._handle.spawn(options);
                         ^

TypeError: Bad argument
    at TypeError (native)
    at ChildProcess.spawn (internal/child_process.js:274:26)
    at exports.spawn (child_process.js:362:9)
    at Object.<anonymous> (C:\Program Files (x86)\nodist\bin\node_modules\phantomjs-prebuilt\bin\phantomjs:22:10)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Function.Module.runMain (module.js:447:10)
    at startup (node.js:139:18)
]
  killed: false,
  code: 1,
  signal: null,
  cmd: 'C:\\Program Files (x86)\\nodist\\bin\\phantomjs.CMD --version' }
like image 577
Rohith Avatar asked Dec 06 '16 09:12

Rohith


1 Answers

As a temporary work around I am able to get it installed by using --ignore-scripts

npm install [email protected] --ignore-scripts

I also logged an issue in the github repo for the same

https://github.com/Medium/phantomjs/issues/649

edited

This issue was part of the build process script I was using and it does a npm clean and install everytime with a bunch of other things .So this issue appears many times in the same machine where we automated tests using phantomjs. I got some time to look into this issue and it seems my corporate proxy is blocking the download from https://github.com/Medium/phantomjs/releases/download/v2.1.1/phantomjs-2.1.1-windows.zip. I knew this before and had manually installed phantomjs binary and added to system path but the npm install still trying to download locally as showing in the log below.

Considering PhantomJS found at C:\npm\phantomjs-2.1.1-windows\bin\phantomjs.EXE
Looks like an `npm install -g` on windows; skipping installed version.

My corporate proxy was blocking all the phantomjs CDN urls as well (https://www.npmjs.com/package/phantomjs)

The work around I used was to get the phantomjs-2.1.1-windows.zip and copy it to the C:\Users\<username>\AppData\Local\Temp\phantomjs\phantomjs-2.1.1-windows.zip and that resolved the issue with the build script.If someone cleans the temp directory,issue will come back. Even this is a work around but the corporate proxy cannot be unblocked for obvious reasons :)

Hope this helps someone!

like image 182
Rohith Avatar answered Sep 18 '22 08:09

Rohith