I want to report a bug.
yarn install fails on a new project.
I downloaded springboot-angular2-tutorial and run yarn install through CLI. First it prompted me that that there is internet issue and it is retrying. After very long time and no movement in progress bar, I pressed Ctrl + C to stop the process. It stopped. And after that when I did yarn install again, it said me to open a issue here with the error log. Here is the trace:
Trace:
SyntaxError: C:\Users\kamle\AppData\Local\Yarn\cache\npm-source-list-map-0.1.6.yarn-metadata.json: Unexpected end of JSON input
at Object.parse (native)
at C:\Program Files (x86)\Yarn\lib\util\fs.js:271:57
at next (native)
at step (C:\Program Files (x86)\Yarn\node_modules\babel-runtime\helpers\asyncToGenerator.js:17:30)
at C:\Program Files (x86)\Yarn\node_modules\babel-runtime\helpers\asyncToGenerator.js:28:20
Nodejs version is 6.8.1
Yarn version is 0.16.0
Windows 10
Can you try yarn cache clean and then yarn install again? It seems you Ctrl + C and corrupted the cache.
I'm having same issue quite often, by running yarn cache clean, re-run console and yarn (install) did worked for me.
For me the issue is persistent, cleaning yarn cache (and all ~/.yarn* stuff) doesn't help.
So, I'm actually seeing the problem with git+https links in my package.json. Here is some sample session with empty app, first yarn invocation takes forever (in this example I ctrl-c it after like 10 seconds), second is ok:
7862 13:35:58 MacBook-Pro ~$ cd tmp
7863 13:35:59 MacBook-Pro ~/tmp$ mkdir yarntest
7864 13:36:03 MacBook-Pro ~/tmp$ cd yarntest
7865 13:36:07 MacBook-Pro ~/tmp/yarntest$ npm init
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.
See `npm help json` for definitive documentation on these fields
and exactly what they do.
Use `npm install <pkg> --save` afterwards to install a package and
save it as a dependency in the package.json file.
Press ^C at any time to quit.
name: (yarntest)
version: (1.0.0)
description:
entry point: (index.js)
test command:
git repository:
keywords:
author:
license: (ISC)
About to write to /Users/nopik/tmp/yarntest/package.json:
{
"name": "yarntest",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
Is this ok? (yes)
7866 13:36:12 MacBook-Pro ~/tmp/yarntest$ npm install --save "git+https://github.com/rebeccahughes/react-native-device-info"
[email protected] /Users/nopik/tmp/yarntest
โโโ [email protected] (git+https://github.com/rebeccahughes/react-native-device-info.git#82e585a515a4169b71a4d57ccd713e65f3c732ec)
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
7867 13:37:21 MacBook-Pro ~/tmp/yarntest$ cat package.json
{
"name": "yarntest",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"react-native-device-info": "git+https://github.com/rebeccahughes/react-native-device-info.git"
}
}
7868 13:37:24 MacBook-Pro ~/tmp/yarntest$ rm -rf node_modules/
7869 13:37:28 MacBook-Pro ~/tmp/yarntest$ yarn
yarn install v0.17.9
info No lockfile found.
[1/4] ๐ Resolving packages...
[2/4] ๐ Fetching packages...
โ 0/1^C
7870 13:37:37 MacBook-Pro ~/tmp/yarntest$ vi package.json
7871 13:38:01 MacBook-Pro ~/tmp/yarntest$ cat package.json
{
"name": "yarntest",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"react-native-device-info": "rebeccahughes/react-native-device-info"
}
}
7872 13:38:04 MacBook-Pro ~/tmp/yarntest$ yarn
yarn install v0.17.9
info No lockfile found.
[1/4] ๐ Resolving packages...
[2/4] ๐ Fetching packages...
[3/4] ๐ Linking dependencies...
[4/4] ๐ Building fresh packages...
success Saved lockfile.
โจ Done in 1.59s.
7873 13:38:09 MacBook-Pro ~/tmp/yarntest$
For me, this is very repeatable. Interestingly, in my package.json I have few other git+https links and they work fine.
For what it's worth I see the same behavior with local file references.
My OS (fedora) crashed during yarn install, and after restart caught by the same issue.
thanks to @torifat, yarn cache clean solved my issue.
My internet got disconnected while yarn was fetching the files and now it shows [2/4] Fetching packages... and progress and stops, cleaning cache didn't help (after clean I have 0/1114k progress and it stops instantly) . I'm using Windows 10 and Ubuntu (WSL).
npm install works fine. Uninstalling yarn and Installing it again also don't work (installed using npm) tried to install from PPA but it don't work self sign SSL error and missing release file.
I'm not sure but maybe this happen on VPN because next day I've run yarn install and it was fine (I've got some error about internet connection but I've change my WiFi to mobile and it was installed successfully).
Most helpful comment
Can you try
yarn cache cleanand thenyarn install again? It seems youCtrl + Cand corrupted the cache.