Medium / phantomjs

NPM wrapper for installing phantomjs
Other
1.42k stars 435 forks source link

Yarn install fails under Linux #673

Closed csvan closed 5 years ago

csvan commented 7 years ago

I have a dependency on 2.1.14, and trying to run yarn install (v0.20.3) on Linux (CentOS) yields the following:

[INFO] [4/4] Building fresh packages...
[ERROR] error /opt/balthazar/workdir/web/node_modules/phantomjs: Command failed.
[ERROR] Exit code: 1
[ERROR] Command: sh
[ERROR] Arguments: -c node install.js
[ERROR] Directory: /opt/balthazar/workdir/web/node_modules/phantomjs
[ERROR] Output:
[ERROR] PhantomJS not found on PATH
[ERROR] Phantom installation failed TypeError: Path must be a string. Received undefined
[ERROR]     at assertPath (path.js:7:11)
[ERROR]     at Object.join (path.js:1211:7)
[ERROR]     at findSuitableTempDirectory (/opt/balthazar/workdir/web/node_modules/phantomjs/install.js:127:30)
[ERROR]     at /opt/balthazar/workdir/web/node_modules/phantomjs/install.js:476:19
[ERROR]     at nextTickCallback (/opt/balthazar/workdir/web/node_modules/kew/kew.js:47:28)
[ERROR]     at _combinedTickCallback (internal/process/next_tick.js:67:7)
[ERROR]     at process._tickCallback (internal/process/next_tick.js:98:9) TypeError: Path must be a string. Received undefined
[ERROR]     at assertPath (path.js:7:11)
[ERROR]     at Object.join (path.js:1211:7)
[ERROR]     at findSuitableTempDirectory (/opt/balthazar/workdir/web/node_modules/phantomjs/install.js:127:30)
[ERROR]     at /opt/balthazar/workdir/web/node_modules/phantomjs/install.js:476:19
[ERROR]     at nextTickCallback (/opt/balthazar/workdir/web/node_modules/kew/kew.js:47:28)
[ERROR]     at _combinedTickCallback (internal/process/next_tick.js:67:7)
[ERROR]     at process._tickCallback (internal/process/next_tick.js:98:9)
[INFO] info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

However, on Windows 7 (Cygwin) it works fine.

Related: https://github.com/yarnpkg/yarn/issues/1016

csvan commented 7 years ago

Update: This is due to https://github.com/yarnpkg/yarn/issues/1538.

PhantomJS should better handle cases where npm_config_tmp is not provided, which will always be the case with Yarn.

chenyulun commented 7 years ago

先全局安装 install phantomjs in global: brew install phantomjs 然后安装能得到正确的提示: PhantomJS is already installed on PATH at /usr/local/bin/phantomjs

dcecile commented 7 years ago

It looks like this has been fixed by 5e6598f3f12f510aada8f5b97f8debdc36b5c160, included in v2.1.8:

if (!candidatePath) continue

Now if the npm_config_tmp environment variable is undefined, it won't get used it to build a test temp path.

(If you're finding this bug because you're using prerender-spa-plugin, that package has an open issue to upgrade from phantomjs-prebuilt v2.1.7 where it's currently stuck due to a Windows problem -- see chrisvfritz/prerender-spa-plugin#36.)

csvan commented 7 years ago

@dcecile I am using 2.1.14 and can confirm that this does not solve the issue unfortunately. The failure still happens.

dcecile commented 7 years ago

@csvan Are you getting the same error as above?

[ERROR] Phantom installation failed TypeError: Path must be a string. Received undefined
[ERROR]     at assertPath (path.js:7:11)
[ERROR]     at Object.join (path.js:1211:7)
[ERROR]     at findSuitableTempDirectory (/opt/balthazar/workdir/web/node_modules/phantomjs/install.js:127:30)
csvan commented 5 years ago

Closing since phantomjs is dead.