Yarn: error An unexpected error occurred: "Unknown token: { line: 1, col: 0, type: 'INVALID', value: undefined }

Created on 11 Mar 2019  路  9Comments  路  Source: yarnpkg/yarn

I get this error whenever I do something with yarn.

C:\Users\chawki\Documents\Project\npm\medium-fetch>yarn publish
yarn publish v1.13.0
error An unexpected error occurred: "Unknown token: { line: 1, col: 0, type: 'INVALID', value: undefined } 1:0 in C:\Users\chawki\.yarnrc".
info If you think this is a bug, please open a bug report with the information provided in "C:\Users\chawki\Documents\Project\npm\medium-fetch\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/publish for documentation about this command.

and its create a yarn error file too.

Arguments:
C:\Program Files\nodejs\node.exe C:\Program Files (x86)\Yarn\bin\yarn.js publish

PATH:
C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Program Files\nodejs\;C:\Program Files\erl10.1\bin;C:\Program Files (x86)\Yarn\bin\;C:\Users\chawki\AppData\Local\Microsoft\WindowsApps;C:\Users\chawki\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\chawki\AppData\Roaming\npm;C:\Exercism;C:\Users\chawki\AppData\Local\hyperapp-2.1.2\resources\bin;C:\MinGW\bin;C:\Users\chawki\AppData\Local\Yarn\bin

Yarn version:
1.13.0

Node version:
10.15.0

Platform:
win32 x64

Trace:
SyntaxError: Unknown token: { line: 1, col: 0, type: 'INVALID', value: undefined } 1:0 in C:\Users\chawki.yarnrc
at Parser.unexpected (C:\Program Files (x86)\Yarn\lib\cli.js:62320:11)
at Parser.parse (C:\Program Files (x86)\Yarn\lib\cli.js:62451:14)
at parse (C:\Program Files (x86)\Yarn\lib\cli.js:62522:17)
at module.exports.exports.default (C:\Program Files (x86)\Yarn\lib\cli.js:62091:96)
at YarnRegistry. (C:\Program Files (x86)\Yarn\lib\cli.js:91555:64)
at Generator.next ()
at step (C:\Program Files (x86)\Yarn\lib\cli.js:304:30)
at C:\Program Files (x86)\Yarn\lib\cli.js:315:13

npm manifest:
{
"name": "md_fetch",
"version": "1.0.1",
"description": "fetch medium post",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Chawki726/md_fetch.git"
},
"author": "@Chawki726",
"license": "MIT",
"bugs": {
"url": "https://github.com/Chawki726/md_fetch/issues"
},
"homepage": "https://github.com/Chawki726/md_fetch#readme"
}

yarn manifest:
No manifest

Lockfile:
No lockfile

Most helpful comment

Maybe your .yarnrc is broken. Try to delete or recreate your .yarnrc.

I also face the similar problem. But in my case, problem is from my yarn.lock.

All 9 comments

Maybe your .yarnrc is broken. Try to delete or recreate your .yarnrc.

I also face the similar problem. But in my case, problem is from my yarn.lock.

Maybe your .yarnrc is broken. Try to delete or recreate your .yarnrc.

I also face the similar problem. But in my case, problem is from my yarn.lock.

i tired but it doesn't work for me

Hi @usama-asfar,

We fix this issue by cleaning the content of .yarnc and save it. and then try the execute you commands.

In my case, recreating .yarnrc or yarn.lock did not help, but upgrading from yarn 1.16.something to 1.17.3 fixed the issue for me.

I got this issue on my windows and I had a switch to ubuntu and yarn is working perfect, I hope those above fix will solve the problem,
Note: I don't switch to ubuntu not because of this :-)

I got the same issue on my windows i fixed this by clearing the .yarnrc file in "c:\user\admin".

I solved mine by deleting the referenced.yarnrc file and running the command again.

remove all data from .yarnrc and save it. [problem Solved]

I don't get how deleting .yarnrc is a solution when it's required in certain circumstances. Seems like all the solutions skirt around the actual problem.

Was this page helpful?
0 / 5 - 0 ratings