Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation Problem: .yarn-metadata.json: Unexpected end of JSON input #660

Closed
reggi opened this issue Oct 11, 2016 · 20 comments
Closed

Installation Problem: .yarn-metadata.json: Unexpected end of JSON input #660

reggi opened this issue Oct 11, 2016 · 20 comments
Labels

Comments

@reggi
Copy link

reggi commented Oct 11, 2016

Seems that yarn is creating a json file without contents and perhaps should be {}.

error SyntaxError: /Users/thomasreggi/.yarn-cache/npm-repeating-1.1.3/.yarn-metadata.json: Unexpected end of JSON input
    at Object.parse (native)
    at Object.<anonymous> (/Users/thomasreggi/.yarn/lib/util/fs.js:260:54)
    at next (native)
    at step (/Users/thomasreggi/.yarn/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
    at /Users/thomasreggi/.yarn/node_modules/babel-runtime/helpers/asyncToGenerator.js:28:20
    at run (/Users/thomasreggi/.yarn/node_modules/core-js/library/modules/es6.promise.js:87:22)
    at /Users/thomasreggi/.yarn/node_modules/core-js/library/modules/es6.promise.js:100:28
    at flush (/Users/thomasreggi/.yarn/node_modules/core-js/library/modules/_microtask.js:18:9)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)
@knownasilya
Copy link

Also seeing this:

Unhandled rejection Error: Command failed: yarn install
warning denali > trash > run-applescript > execa > cross-spawn-async@2.2.4: cross-spawn no longer requires a build toolchain, use it instead!
error SyntaxError: /Users/iradchenko/.yarn-cache/npm-morgan-1.7.0/.yarn-metadata.json: Unexpected end of JSON input
    at Object.parse (native)
    at Object.<anonymous> (/Users/iradchenko/.nave/installed/6.7.0/lib/node_modules/yarn/lib/util/fs.js:260:54)
    at next (native)
    at step (/Users/iradchenko/.nave/installed/6.7.0/lib/node_modules/yarn/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
    at /Users/iradchenko/.nave/installed/6.7.0/lib/node_modules/yarn/node_modules/babel-runtime/helpers/asyncToGenerator.js:28:20

@ide
Copy link
Contributor

ide commented Oct 14, 2016

We hit this at Exponent after getting a prior installation error due to a bad hash in the yarn.lock file. Current hypothesis is that a bad hash or other installation error causes Yarn to bail out and not properly clean up .yarn-metadata.json files.

@markstos
Copy link
Contributor

I triggered this condition after a failed install of lodash.isfunction:

[2/4] Fetching packages...
error https://registry.npmjs.org/lodash.isfunction/-/lodash.isfunction-2.4.1.tgz: invalid tar file
    at Extract.Parse._startEntry (/usr/local/lib/node_modules/yarn/node_modules/tar/lib/parse.js:149:13)
    at Extract.Parse._process (/usr/local/lib/node_modules/yarn/node_modules/tar/lib/parse.js:131:12)
    at BlockStream.<anonymous> (/usr/local/lib/node_modules/yarn/node_modules/tar/lib/parse.js:47:8)
    at emitOne (events.js:77:13)
    at BlockStream.emit (events.js:169:7)
    at BlockStream._emitChunk (/usr/local/lib/node_modules/yarn/node_modules/block-stream/block-stream.js:145:10)
    at BlockStream.write (/usr/local/lib/node_modules/yarn/node_modules/block-stream/block-stream.js:45:10)
    at Extract.Parse.write (/usr/local/lib/node_modules/yarn/node_modules/tar/lib/parse.js:81:23)
    at UnpackStream.ondata (_stream_readable.js:536:20)
    at emitOne (events.js:77:13)
    at UnpackStream.emit (events.js:169:7)

If you trigger this, you can workaround the issue with:

yarn cache clean

Then try your install again. In my case, the re-try worked.

@jkingdon
Copy link

We were getting this on yarn 0.22 (installed via npm). We resolved it by upgrading to yarn 0.23.1 (installed via apt) and then running yarn cache clean.

@bestander
Copy link
Member

Should be fixed now

@m4v0
Copy link

m4v0 commented Jan 31, 2018

Set the problem with the command "native command-inactive "
After running the "yarn cache clean" command, it worked normally, thanks for the tip.

@Musigwa-zz
Copy link

Command failed: yarn add react-navigation@1.0.0-beta.11
error An unexpected error occurred: "/home/musigwa/.cache/yarn/v1/npm-react-native-tab-view-0.0.65-b685ea3081ff7c96486cd997361026c407302c59/.yarn-metadata.json: Unexpected end of JSON input".

i got this error while running ignite new FirstApp

@Musigwa-zz
Copy link

anyone to help me???

@bestander
Copy link
Member

@Musigwa, looks like your cache might be corrupt.
Try running yarn cache clean and then install again

@Musigwa-zz
Copy link

thank you i'm going to try it out

@Musigwa-zz
Copy link

Musigwa-zz commented Mar 14, 2018 via email

@daoyi7
Copy link

daoyi7 commented Apr 24, 2019

I triggered this condition after a failed install of lodash.isfunction:

[2/4] Fetching packages...
error https://registry.npmjs.org/lodash.isfunction/-/lodash.isfunction-2.4.1.tgz: invalid tar file
    at Extract.Parse._startEntry (/usr/local/lib/node_modules/yarn/node_modules/tar/lib/parse.js:149:13)
    at Extract.Parse._process (/usr/local/lib/node_modules/yarn/node_modules/tar/lib/parse.js:131:12)
    at BlockStream.<anonymous> (/usr/local/lib/node_modules/yarn/node_modules/tar/lib/parse.js:47:8)
    at emitOne (events.js:77:13)
    at BlockStream.emit (events.js:169:7)
    at BlockStream._emitChunk (/usr/local/lib/node_modules/yarn/node_modules/block-stream/block-stream.js:145:10)
    at BlockStream.write (/usr/local/lib/node_modules/yarn/node_modules/block-stream/block-stream.js:45:10)
    at Extract.Parse.write (/usr/local/lib/node_modules/yarn/node_modules/tar/lib/parse.js:81:23)
    at UnpackStream.ondata (_stream_readable.js:536:20)
    at emitOne (events.js:77:13)
    at UnpackStream.emit (events.js:169:7)

If you trigger this, you can workaround the issue with:

yarn cache clean

Then try your install again. In my case, the re-try worked.

thx

@wptechprodigy
Copy link

wptechprodigy commented Jun 28, 2019

This might help someone...perhaps, I might be needing it in the future.
It's not uncommon in this space...

I was having this issue while trying to work on a project that required using yarn. So I ran yarn and was receiving this error message:


yarn install v1.16.0  
[1/4] Resolving packages...
[2/4] Fetching packages...
error An unexpected error occurred: "C:\\Users\\MumsyIre\\AppData\\Loc al\\Yarn\\Cache\\v4\\npm-escape-string-regexp-1.0.5-1b61c0562190a8dff6 ae3bb2cf0200ca130b86d4\\node_modules\\escape-string-regexp\\.yarn-meta data.json: Unexpected token \u0000 in JSON at position 0".
info If you think this is a bug, please open a bug report with the inf ormation provided in "C:\\Users\\MumsyIre\\Desktop\\MyFiles\\operation al-ui\\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation a bout this command.
--

Problem: Corrupt cache
Solution: Clean up your cache by running yarn cache clean

Source: @bestander
Thanks @bestander

@MrGlaurung
Copy link

Don't forget that if you get this error on windows it can be because you have an empty package.json in your home directory (C:\Users\yourlogin\package.json).

If you have the empty file there just delete it and you are on track again.

@malte1989
Copy link

Don't forget that if you get this error on windows it can be because you have an empty package.json in your home directory (C:\Users\yourlogin\package.json).

If you have the empty file there just delete it and you are on track again.

You really saved my life! I tried all possible things and hunderts of reinstalls... :-)

@shog86
Copy link

shog86 commented Apr 28, 2020

Don't forget that if you get this error on windows it can be because you have an empty package.json in your home directory (C:\Users\yourlogin\package.json).

If you have the empty file there just delete it and you are on track again.

Thank you! This also solved my problem with yarn!

@AmazingTurtle
Copy link

I'm running the yarn install procedure within a Dockerfile, there's no cache. It's retrieving the dependencies directly from a registry. Why is this still a thing? Also I have seen this issue with icu4c-data/.yarn-metadata.json most of the time.

@radiorz
Copy link

radiorz commented May 17, 2021

thanks, yarn cache clean do helps me.

@gepthecoder
Copy link

In Windows first stop the development server and then try to install package.

@danielrsantana-humaitrix

If you are unable to run yarn cache clean because of the same error, your package.json file is probably empty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests