Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issue while installing YARN

I am trying to install YARN through npm. but I am getting errors.

By running

npm install --global yarn

I see the following:

  % npm install --global yarn                                                                                           !457
npm ERR! code EEXIST
npm ERR! path /usr/local/bin/yarn
npm ERR! EEXIST: file already exists
npm ERR! File exists: /usr/local/bin/yarn
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/tripurjoshi/.npm/_logs/2023-03-22T07_06_33_396Z-debug-0.log

I am seeing the following results when i try to see the version of the yarn through

yarn --version
`/usr/local/lib/node_modules/corepack/dist/corepack.js:43896
      import_process.default.env.XDG_CACHE_HOME ?? import_process.default.env.LOCALAPPDATA ?? (0, import_path.join)(
                                                 ^

SyntaxError: Unexpected token '?'
    at wrapSafe (internal/modules/cjs/loader.js:915:16)
    at Module._compile (internal/modules/cjs/loader.js:963:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/corepack/dist/yarn.js:2:1)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
`
like image 726
Tripur Joshi Avatar asked Aug 12 '26 19:08

Tripur Joshi


1 Answers

You just need to install corepack not yarn, the command is npm i -g corepack.

If still getting some erros, just install an older version of corepack, that solved for me!

like image 117
Brayan Freitas Avatar answered Aug 17 '26 16:08

Brayan Freitas