Yarn: TypeError: Reduce of empty array with no initial value

Created on 24 May 2018  Â·  28Comments  Â·  Source: yarnpkg/yarn

What is the current behavior? Installing dependencies fails with error An unexpected error occurred: "Reduce of empty array with no initial value".

If the current behavior is a bug, please provide the steps to reproduce.

This is the simplest reproduction I've been able to create. The result should look something like this: https://github.com/spalger/reproduce-issues/tree/master/yarn-reduce-of-empty-array-without-initial-value

error log: https://github.com/spalger/reproduce-issues/blob/master/yarn-reduce-of-empty-array-without-initial-value/bar/yarn-error.log

# create two packages
mkdir foo bar

# install `tree-kill` dependency in `foo`
cd foo && yarn init -y && yarn add tree-kill

# link to `foo` from bar
cd ../bar && yarn init -y && yarn add link:../foo

yarn add in bar should fail.

What is the expected behavior? yarn add should not fail with internal error

Please mention your node.js, yarn and operating system version.
node -v: v8.11.0
yarn -v: 1.7.0

triaged

Most helpful comment

Temporary workaround until patch release (works for me): remove node_modules, install without links, then add links back.

rm -rf node_modules
yarn
yarn link myProject

All 28 comments

@spalger i can try to look into this tonight.

I think I've found this issue and I'll have a PR up tonight. cc @bestander

ping me when PR is ready

@bestander #5879

Thanks @bestander and @bdwain!

Any idea when this will land as a point release like 1.7.1 ? i just got bit by the link problem...

Temporary workaround until patch release (works for me): remove node_modules, install without links, then add links back.

rm -rf node_modules
yarn
yarn link myProject

In the meantime, the nightly builds should already be available with this
fix.

https://yarnpkg.com/lang/en/docs/nightly/

On Fri, May 25, 2018, 6:23 PM Kevin Cooper notifications@github.com wrote:

Temporary workaround until patch release (works for me): remove
node_modules, install without links, then add links back.

rm -rf node_modules
yarn
yarn link myProject

—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
https://github.com/yarnpkg/yarn/issues/5876#issuecomment-392125789, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AA_Wa3zGgfDOdB6_ZURgx3fJa29BhrCbks5t2D4fgaJpZM4UMrRP
.

I already did this (on MacOS)

$ brew unlink yarn

$ brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/76215230de5f7f7bee2cfcdd7185cf49d949862d/Formula/yarn.rb

$ brew switch yarn 1.6.0_1

Many thanks to @nothingismagick for the workaround.

I don't understand how a bug this serious made it into a release of mission-critical software like Yarn.

Yeah, its kind of a weird situation. Over at https://github.com/quasarframework/quasar I have been championing Yarn - especially for our devs working on core. Being able to so effortlessly link (and not accidentally destroy the linked folder!!!) with yarn is a huge selling point. Telling them to downgrade makes me feel silly. :(

By the way, there are several ways to "link", and the one I currently prefer is e.g.:

yarn add "quasar-cli@link:../quasar-cli"

This way I don't have to run the link command in the quasar-cli folder and the target folder. This is nice when you need to have multiple versions and DON'T want a global link polluting your work.

Oh, thanks, I didn't know about that. (We have _almost_ entirely managed to stop using yarn link, finding that workspaces do most of what we need.)

Perhaps Yarn shouldn't encourage people to upgrade to a new major version until it has been out a while? I only upgraded because Yarn suggested it. Now my projects are broken.

Though, I'm sure this is a rare thing that such a big feature goes haywire and it gets released that way.

Will there be a point release 1.7.1 or is 1.8.0 coming too soon?
Anyone in my team that starts with or updates to the latest stable yarn runs into this issue.

Yarn 1.8 has been released two weeks ago: https://github.com/yarnpkg/yarn/releases

I'll move it to stable tomorrow since we haven't got critical reports yet, but you can already install it from various ways (for example with npm, npm install -g yarn@rc should do the trick).

According to https://yarnpkg.com/en/docs/install#mac-rc, 1.7.0 is still the release candidate. (It's also the stable version of course.)

But yes, RC is 1.8.0 on NPM.

This is kind of silly but it's working for me

npx yarn@rc add <package>

@arcanis any update on moving yarn 1.8 to stable?

Others recommended a rm -rf node_modules and then re-yarn-install. But I just had to

yarn unlink PACKAGE
yarn
yarn link PACKAGE

I cannot install last yarn 1.8.0 from choco install [email protected] or choco install yarn@rc - error: package did not found. Also if I try to make it throw npm install -g yarn@rc I gets installed yarn v.1.8.0 on my machine, but really, when I try to run yarn info or yarn versions - I see yarn v.1.7.0 in log. Miracle...

The version of Yarn from Choco is winning, which is why you are seeing 1.7.x. You’ll have to use Choco to uninstall Yarn. Then the NPM-installed version will be the one to execute.

Whoever maintains packages for Chico’s Yarn installer does not create an installer for release candidates. Just releases. So whenever v1.8.0 actually gets released, you can use Choco (pending an update from them) to install Yarn again.

It’s unfortunate that this is still an issue.

~Don

On Jul 12, 2018, at 2:07 AM, Sviat Kuzhelev notifications@github.com wrote:

Cannot install last yarn 1.8.0 from choco install [email protected] or choco install yarn@rc - error: package did not founded. Also if I try to make it throw npm install -g yarn@rc I got installed yarn v.1.8.0, but really when I try yarn info or yarn versions - I see yarn v.1.7.0 in log. Miracle...

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

@arcanis thanks ! :+1:

as a workaround you can do (on MacOS) until 1.8.0 lands in brew

brew unlink yarn
brew install https://raw.githubusercontent.com/joscha/homebrew-core/a6f904aac4df702cfff11d94d5fd257f841bffa2/Formula/yarn.rb

@arcanis v1.7.0 is still listed as the stable version and v1.8.0 seems to have been taken off the RC list on https://yarnpkg.com/en/docs/install#windows-stable. Is there a window installer I can get for v1.8.0 somewhere?

The latest version of yarn is 1.9.2 already, just upgrade your yarn.

https://yarnpkg.com/en/package/yarn

hey i got 2 times today on bot.binary.com
using a robot error
Reduce an empty array with no initial value

72040927-bfb37c80-32b2-11ea-9ac3-c86e95b63d0a

Was this page helpful?
0 / 5 - 0 ratings