Skip to content

npm install -g yarn #6

Closed
Closed
@arcanis

Description

@arcanis

With pmm currently installed, the following currently happens when running npm install -g yarn:

npm ERR! code EEXIST
npm ERR! syscall symlink
npm ERR! path ../lib/node_modules/yarn/bin/yarn.js
npm ERR! dest /tmp/tmp.SfN0q4jxL7/node-v15.0.0-nightlyYYYY-MM-DDXXXX-linux-x64/bin/yarn
npm ERR! errno -17
npm ERR! EEXIST: file already exists, symlink '../lib/node_modules/yarn/bin/yarn.js' -> '/tmp/tmp.SfN0q4jxL7/node-v15.0.0-nightlyYYYY-MM-DDXXXX-linux-x64/bin/yarn'
npm ERR! File exists: /tmp/tmp.SfN0q4jxL7/node-v15.0.0-nightlyYYYY-MM-DDXXXX-linux-x64/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/arcanis/.npm/_logs/2020-09-03T14_30_46_868Z-debug.log

There are a few options on the ideal behavior:

  • Ask npm to assume --force when overriding the yarn binary (or any other binary covered by pmm). Pros, it preserves the current behavior, anyone who runs npm install -g yarn can keep doing it without changing their workflows. Cons, it means that they would effectively be replacing the pmm binary, so they wouldn't benefit from the "ensures the right version" anymore.

  • Ask npm to exit with a zero exit code when it detects that the yarn binary points to pmm, and print a message explaining the situation with a link to the pmm project. Perhaps we could also make it change the default Yarn version that pmm would use for new projects. Pros, people can keep using their workflow, they don't accidentally overwrite their binaries and lose features. Cons, it's a bit magical, might be confusing to some users.

  • Decide that this is the expected behavior, and that people upgrading to Node 15.x are expected to be aware that running npm install -g yarn isn't needed anymore. Potentially ask npm to improve the error message to explain the situation. Pros, fail early, this would make this improvement noticeable. Cons, it's maybe too noticeable, and CI providers would need to adapt to this change.

For reference, the ideal message I mention would be akin to:

npm ERR! Starting from Node 15.x, Yarn is partially distributed along with Node. To check that
npm ERR! is the case, run `yarn --version` in your project directory. More information on:
npm ERR!     https://nodejs.org/pmm/notice

With the url pointing to longer explanations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions