yarn icon indicating copy to clipboard operation
yarn copied to clipboard

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

Open reggi opened this issue 10 years ago • 20 comments

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)

reggi avatar Oct 11 '16 17:10 reggi

Also seeing this:

Unhandled rejection Error: Command failed: yarn install
warning denali > trash > run-applescript > execa > [email protected]: 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

knownasilya avatar Oct 12 '16 15:10 knownasilya

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.

ide avatar Oct 14 '16 05:10 ide

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.

markstos avatar Oct 17 '16 19:10 markstos

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.

jkingdon avatar Apr 17 '17 20:04 jkingdon

Should be fixed now

bestander avatar May 23 '17 14:05 bestander

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

m4v0 avatar Jan 31 '18 00:01 m4v0

Command failed: yarn add [email protected] 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 avatar Mar 05 '18 16:03 Musigwa-zz

anyone to help me???

Musigwa-zz avatar Mar 05 '18 17:03 Musigwa-zz

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

bestander avatar Mar 05 '18 17:03 bestander

thank you i'm going to try it out

Musigwa-zz avatar Mar 05 '18 17:03 Musigwa-zz

Thanks at all it worked fine

On Mon, Mar 5, 2018, 19:39 Konstantin Raev [email protected] wrote:

@Musigwa https://github.com/musigwa, looks like your cache might be corrupt. Try running yarn cache clean and then install again

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

Musigwa-zz avatar Mar 14 '18 08:03 Musigwa-zz

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

devtorich avatar Apr 24 '19 13:04 devtorich

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

wptechprodigy avatar Jun 28 '19 12:06 wptechprodigy

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.

MrGlaurung avatar Sep 27 '19 06:09 MrGlaurung

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

malte1989 avatar Nov 19 '19 09:11 malte1989

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!

shog86 avatar Apr 28 '20 14:04 shog86

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.

AmazingTurtle avatar Jul 10 '20 12:07 AmazingTurtle

thanks, yarn cache clean do helps me.

radiorz avatar May 17 '21 07:05 radiorz

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

gepthecoder avatar May 14 '22 08:05 gepthecoder

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