Yarn: Bug. Yarn couldn't build package phantomjs. npm could.

Created on 13 Oct 2016  ·  32Comments  ·  Source: yarnpkg/yarn

I tried to build this project Github, npm installed all node_modules without errors. But when I tried to do this with Yarn I have got error.
os Archliux 64bit
node v6.7.0
yarn v0.15.1

Building fresh packages... [1/6] ⠁ gifsicle [2/6] ⠁ jpegtran-bin [3/6] ⠁ optipng-bin [6/6] ⠁ phantomjs error /usr/share/nginx/html/123/Travel-Site-Test/node_modules/phantomjs: Command failed. Exit code: 1 Command: sh Arguments: -c node install.js Directory: /usr/share/nginx/html/123/Travel-Site-Test/node_modules/phantomjs Output: PhantomJS not found on PATH Phantom installation failed TypeError: Path must be a string. Received undefined at assertPath (path.js:7:11) at Object.join (path.js:1213:7) at findSuitableTempDirectory (/usr/share/nginx/html/123/Travel-Site-Test/node_modules/phantomjs/install.js:127:30) at /usr/share/nginx/html/123/Travel-Site-Test/node_modules/phantomjs/install.js:476:19 at nextTickCallback (/usr/share/nginx/html/123/Travel-Site-Test/node_modules/kew/kew.js:47:28) at _combinedTickCallback (internal/process/next_tick.js:67:7) at process._tickCallback (internal/process/next_tick.js:98:9) TypeError: Path must be a string. Received undefined at assertPath (path.js:7:11) at Object.join (path.js:1213:7) at findSuitableTempDirectory (/usr/share/nginx/html/123/Travel-Site-Test/node_modules/phantomjs/install.js:127:30) at /usr/share/nginx/html/123/Travel-Site-Test/node_modules/phantomjs/install.js:476:19 at nextTickCallback (/usr/share/nginx/html/123/Travel-Site-Test/node_modules/kew/kew.js:47:28) at _combinedTickCallback (internal/process/next_tick.js:67:7) at process._tickCallback (internal/process/next_tick.js:98:9) at SpawnError (/usr/lib/node_modules/yarn/lib/errors.js:18:1) at ChildProcess.proc.on.code (/usr/lib/node_modules/yarn/lib/util/child.js:107:15) at emitTwo (events.js:106:13) at ChildProcess.emit (events.js:191:7) at maybeClose (internal/child_process.js:877:16) at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)

Most helpful comment

Having the issue.
yarn v.0.19.1

"devDependencies": {
  ...  
  "karma-phantomjs-launcher": "1.0.2",
  "phantomjs": "2.1.7"
}

yarn --no-bin-links

PhantomJS not found on PATH
Phantom installation failed [TypeError: Path must be a string. Received undefined] TypeError: Path must be a string. Received undefined

All 32 comments

I think i opened a similar issue: https://github.com/yarnpkg/yarn/issues/1015

Looks like a dupe of #987, which also mentions a failed PhantomJS installation. (#1015 mentioned above was closed as a dupe of the same ticket).

It is not exactly duplicate. They fixed it in stringstream, but it still does not work in PhantomJS. I would reopen it.

@igorshubovych did you try phantomjs-prebuilt instead (which is the latest version of phantomjs)? I wonder if the old phantomjs package was itself buggy, but npm happened to work with it.

Updating phantomjs-prebuilt to v2.1.8 fixed the problem for me.

I can reproduce the issue.
I have [email protected] and [email protected].

When I run yarn install I get the following error:

error /media/willem/DATA/Projects/Essent/service-api/node_modules/phantomjs: Command failed
...
Output
PhantomJS not found on PATH
Phantom installation failed TypeError: Path must be a string. Received undefined

With npm install PhantomJS installs fine.

Why was this issue closed?

I'm having the same issue here.
I've already tried all solutions above.

Having the issue.
yarn v.0.19.1

"devDependencies": {
  ...  
  "karma-phantomjs-launcher": "1.0.2",
  "phantomjs": "2.1.7"
}

yarn --no-bin-links

PhantomJS not found on PATH
Phantom installation failed [TypeError: Path must be a string. Received undefined] TypeError: Path must be a string. Received undefined

@markstos Can this be reopened? A few people have been experiencing this issue after #987 was closed. Thanks!

@ilaif I don't have the ability to re-open it, but I'll mention @cpojer who does.

I still recommend using phantomjs-prebuilt instead (which is the latest version of phantomjs). With so many open issues, I could understand if the Yarn project chooses not to allocate resources fixing compatibility with an old, buggy package when yarn already works with the newer, recommended version of the package.

seeing this in [email protected] also

@markstos this is not an issue with the old package only. I can reproduce this with yarn 0.20.3 and phantomjs-prebuilt 2.1.14.

However, this is only reproducible under Linux. On Windows 7 under Cygwin it works fine.

@cpojer please consider reopening this as it clearly isn't resolved. A lot of build environments depend on phantomjs for testing etc, so this is a major blocker for using Yarn in them.

@csvan Could you post the output of your failure to build phantomjs-prebuilt on Linux?

@markstos Good day. There is no more problem with yarn and package phantomjs-prebuilt. I installed it successfully just now.
OS: Arch Linux 4.9.9-1
nodejs: v7.5.0
yarn: v0.21.3

Thanks to all

xm@localhost:http/testtest $ yarn add phantomjs-prebuilt yarn add v0.21.3 info No lockfile found. [1/4] Resolving packages... [2/4] Fetching packages... [3/4] Linking dependencies... [4/4] Building fresh packages... success Saved lockfile. success Saved 90 new dependencies.

@markstos getting this on CentOS 7 when running yarn install in a project with "phantomjs-prebuilt": "^2.1.14" as a dep. Using Node 6.9.5. and Yarn 0.20.3:

[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.

@csvan Your failure is in "findSuitableTempDirectory". You apparently don't have permission to write to several possible temp directories on your system. See:

https://github.com/Medium/phantomjs/blob/master/install.js#L105

That appears to be your problem, not yarns. Try again after setting your own environment variable to a working value: npm_config_tmp=/some/tmp/dir/you/can/actually/write/to yarn install.

I used yarn to install phantomjs-prebuilt without problems (on Ubuntu Linux).

@markstos great catch, I will try that. Does NPM do this by default? The above project builds fine with NPM 3.10, it only fails under Yarn.

@markstos nvm, just noticed NPM does set this var whereas Yarn doesn't. My problem is thus actually this issue: https://github.com/yarnpkg/yarn/issues/1538. Thanks for your help!

This toolset works for me

node: v6.9.4
yarn: 0.21.3
"karma-phantomjs-launcher": "^1.0.2",
"phantomjs-prebuilt": "2.1.8",

It looks like this has been fixed in phantomjs-prebuilt v2.1.8 via Medium/phantomjs@5e6598f.

(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.)

If you switch over to phantomjs-prebuilt to solve this problem, you then can't run it in an Alpine based docker container as it's not built for musl... so you also have to change your Linux distro... or make a custom build of phantom

For anyone still having this issue, I recommend switching over to Chrome Headless. It does everything phantom does better, and is actively supported across all platforms.

@mikestead How does that work? Do I have to remove the launcher?

The same problem

@xahon maybe you can try https://github.com/yarnpkg/yarn/issues/1538#issuecomment-325136897?

I had the same problem,try yarn global add phantomjs-prebuilt.

same problem

@dapi you should provide the version of phantom that you are having trouble installing. Try 2.1.16 (or newer)

What @markstos said except also replace phantomjs with phantomjs-prebuilt in package.json.

I had the same issue, it works installing [email protected]

This works for me:

TMPDIR=/tmp yarn install

Adding phantomjs-prebuilt to the global packages fixed it for me.

I had the same problem,try yarn global add phantomjs-prebuilt.

Was this page helpful?
0 / 5 - 0 ratings