Yarn: Cannot globally install any package: "expected manifest"

Created on 14 Nov 2016  路  19Comments  路  Source: yarnpkg/yarn

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
Output when trying to install create-react-app as it's the example here.

yarn global v0.17.0
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
error An unexpected error occurred: "expected manifest".
info If you think this is a bug, please open a bug report with the information provided in "/home/bas/.config/yarn/global/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/global for documentation about this command.

From the log:

Trace:
  Invariant Violation: expected manifest
      at invariant (/home/bas/n/lib/node_modules/yarn/node_modules/invariant/invariant.js:42:15)
      at PackageResolver.getStrictResolvedPattern (/home/bas/n/lib/node_modules/yarn/lib/package-resolver.js:401:5)
      at GlobalAdd.maybeOutputSaveTree (/home/bas/n/lib/node_modules/yarn/lib/cli/commands/global.js:185:38)
      at /home/bas/n/lib/node_modules/yarn/lib/cli/commands/add.js:162:19
      at Generator.next (<anonymous>)
      at step (/home/bas/n/lib/node_modules/yarn/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
      at /home/bas/n/lib/node_modules/yarn/node_modules/babel-runtime/helpers/asyncToGenerator.js:28:13

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

  • Try to globally install any package (e.g.: yarn global add create-react-app)

What is the expected behavior?
Should globally install the package.

Please mention your node.js, yarn and operating system version.
Node: 7.1.0
Yarn: 0.17.0
OS: Antergos Linux release 16.6 (ISO-Rolling), Linux version 4.8.7-1-ARCH

cat-bug

Most helpful comment

Workaround

If you want a workaround right now for installing global packages, use @latest after the package name, e.g.

yarn global add webpack@latest

This works with any exact version, dist-tag or any semver range:

yarn global add webpack@latest # equivalent to: yarn global add webpack
yarn global add [email protected] # explicit version
yarn global add [email protected] # prerelease version
yarn global add webpack@beta # a custom dist-tag published for webpack
yarn global add webpack@^1.13.1 # semver range, will install 1.13.3
yarn global add webpack@\* # will also install 1.13.3

As far as I can tell, you just need an @ plus something/anything semver can parse.

All 19 comments

Same error with jscodeshift

yarn global add jscodeshift

Node: 7.1.0
yarn: 0.17.0
macOS 10.12.2

Please mention your node.js, yarn and operating system version.
Node: 7.1.0
Yarn: 0.17.0
OS: Antergos Linux release 16.6 (ISO-Rolling), Linux version 4.8.7-1-ARCH

Can confirm on macOS 10.11.6 as well (same versions for everything else).

Fix Invariant Violation: expected manifest from GlobalAdd (regressed by #1757)

diff --git a/src/cli/commands/global.js b/src/cli/commands/global.js
--- a/src/cli/commands/global.js
+++ b/src/cli/commands/global.js
@@ -17,7 +17,7 @@ import * as fs from '../../util/fs.js';

 class GlobalAdd extends Add {
   maybeOutputSaveTree(): Promise<void> {
-    for (const pattern of this.args) {
+    for (const pattern of this.addedPatterns) {
       const manifest = this.resolver.getStrictResolvedPattern(pattern);
       ls(manifest, this.reporter, true);
     }

Can't install any package globally here either. macOS 10.12.1.

Same problem on Ubuntu (as expected from the macOS reports above)
yarn global add webpack

Same thing here. yarn global add coffee-script on c9.io

yarn global add gulp-cli doesn't work on circleCI

OK. Was on node 4.6.1, with nvm, and switched to 7.1.0 and now it works. Never mind, it actually doesn't. :sob:

Also confirming the issue.

Same issue here

Workaround

If you want a workaround right now for installing global packages, use @latest after the package name, e.g.

yarn global add webpack@latest

This works with any exact version, dist-tag or any semver range:

yarn global add webpack@latest # equivalent to: yarn global add webpack
yarn global add [email protected] # explicit version
yarn global add [email protected] # prerelease version
yarn global add webpack@beta # a custom dist-tag published for webpack
yarn global add webpack@^1.13.1 # semver range, will install 1.13.3
yarn global add webpack@\* # will also install 1.13.3

As far as I can tell, you just need an @ plus something/anything semver can parse.

same issue

Same issue, but if I install grunt-cli package with yarn global add grunt-cli@latest, the command grunt was not found and not linked in /usr/bin folder.

nodemon is also not linked using @latest

Same issue with yarn global add code-push-cli

For anyone who needs to rollback while waiting for this fix, first uninstall the current version of yarn and then just do:

npm i -g [email protected]

Make sure to uninstall and then reinstall global dependencies to include bin linking.

yarn global remove ...
yarn global add ...

@arxpoetica could you please provide more details about the following?

Make sure to uninstall and then reinstall global dependencies to include bin linking.
yarn global remove ...
yarn global add ...

because after doing a rollback to yarn 0.16.1, I get the following error when running yarn

/usr/local/lib/node_modules/yarn/bin/yarn.js:47
      throw err;
      ^

Error: ENOENT: no such file or directory, open '/usr/local/lib/node_modules/yarn/updates/0.17.0/lib/cli/index.js'
    at Object.fs.openSync (fs.js:557:18)
    at Object.fs.readFileSync (fs.js:467:33)
    at Object.Module._extensions..js (module.js:581:20)
    at Module.load (module.js:490:32)
    at tryModuleLoad (module.js:449:12)
    at Function.Module._load (module.js:441:3)
    at Module.require (module.js:500:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/usr/local/lib/node_modules/yarn/bin/yarn.js:39:22)
    at Module._compile (module.js:573:32)

@iraklisg I'm not sure I'll be much help, but good news, they've releases a fix in 0.17.2, so you can install the latest version of Yarn, and should be good to go.

https://github.com/yarnpkg/yarn/releases/tag/v0.17.2

@arxpoetica, indeed, I have updated yarn to v0.17.3 and everything seems to work fine thus far

Was this page helpful?
0 / 5 - 0 ratings