New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Yarn to manage dependencies #38481

Merged
merged 43 commits into from Nov 16, 2017

Conversation

Projects
None yet
7 participants
@joaomoreno
Member

joaomoreno commented Nov 16, 2017

cc @felixfbecker

We moved to Yarn to manage our dependencies. The big advantage is, of course, speed. I report 3x faster install times on my macOS machine. There are other consequences such as locking down our dev dependencies (which sometimes bite us: #37698, et al).


For everyone in @Microsoft/vscode, please read:

What do I have to do?

  1. Update Node to the latest stable version (currently: 8.9.1).
  2. Install Yarn globally: npm i -g yarn
  3. Clean up your vscode repo: git clean -xfd
  4. Install all dependencies: yarn. You can now have a very short espresso ☕️ while you wait Compare that to the tall venti moccachino soy latte from the good old npm 4 times. Too many calories.

You're good to go.

FAQ

How do I do ./scripts/npm.sh install now?

Just:

yarn

Pretty cool, amirite?

I've also adapted scripts/npm.{sh,bat} to simply invoke yarn for the sanity of your own muscle memory.

What about npm run TASK?

You can still do that. No problem.

How can I add or update a dependency?

Both installing and updating dependencies are the same command:

yarn add [--dev] dependency[@version]

Example:

yarn add semver@4.3.6

As always, carefully review the changes made to package.json and (now) yarn.lock files before blindly committing them when adding or updating dependencies.

What are yarn.lock files?

They replace our shrinkwrap files and represent a snapshot of the dependencies to install when installing... dependencies. You don't touch them. Only Yarn touches them.

Can I manually edit dependencies in package.json or yarn.lock?

No, since those files should only be managed by Yarn itself.

On Windows, yarn fails with EBUSY errors

Yarn tries to parallelise native module compilation in order to be faster. node-gyp doesn't like this on Windows. You can set CHILD_CONCURRENCY to 1 in your user's environment to fix this.

Why not NPM5?

Basically because of npm/npm#17722


As always, please be alert to any runtime errors, missing dependencies, strangeness; and let me know asap.

joaomoreno added some commits Nov 15, 2017

@joaomoreno joaomoreno added this to the November 2017 milestone Nov 16, 2017

@joaomoreno joaomoreno self-assigned this Nov 16, 2017

@joaomoreno joaomoreno changed the title from Use yarn to Use yarn to manage dependencies Nov 16, 2017

@joaomoreno joaomoreno changed the title from Use yarn to manage dependencies to Use Yarn to manage dependencies Nov 16, 2017

@joaomoreno joaomoreno merged commit 67cd925 into master Nov 16, 2017

4 of 5 checks passed

continuous-integration/appveyor/branch Waiting for AppVeyor build to complete
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
license/cla All CLA requirements met.
Details

@joaomoreno joaomoreno deleted the joao/yarn branch Nov 16, 2017

@joaomoreno joaomoreno referenced this pull request Nov 16, 2017

Closed

Support NPM5 #30134

@joaomoreno

This comment has been minimized.

Show comment
Hide comment
@joaomoreno

joaomoreno Nov 16, 2017

Member

@bpasero @Tyriar FYI the electronVersion flag is gone from package.json. You gotta edit the .yarnrc file now, when updating Electron: https://github.com/Microsoft/vscode/blob/master/.yarnrc#L2

Member

joaomoreno commented Nov 16, 2017

@bpasero @Tyriar FYI the electronVersion flag is gone from package.json. You gotta edit the .yarnrc file now, when updating Electron: https://github.com/Microsoft/vscode/blob/master/.yarnrc#L2

@octref

This comment has been minimized.

Show comment
Hide comment
@octref

octref Nov 16, 2017

Member

One tip I found useful: yarn <command> will fallback to yarn run <command> if the first command is not a top level one. This makes it really easy for me to run npm scripts. I run yarn compile all the time.

Member

octref commented Nov 16, 2017

One tip I found useful: yarn <command> will fallback to yarn run <command> if the first command is not a top level one. This makes it really easy for me to run npm scripts. I run yarn compile all the time.

@Stanzilla

This comment has been minimized.

Show comment
Hide comment
@Stanzilla

Stanzilla Dec 11, 2017

yarn config set child-concurrency 1 to set the option.

Stanzilla commented Dec 11, 2017

yarn config set child-concurrency 1 to set the option.

@brettcannon brettcannon referenced this pull request Dec 14, 2017

Closed

Move to using yarn #421

@Favna

This comment has been minimized.

Show comment
Hide comment
@Favna

Favna Dec 20, 2017

Concerning this line:

Install Yarn globally: npm i -g yarn

Yarn themselves recommend installing Yarn through other means than the node package manager for Linux and MacOS with the former varying on the distro and the latter having options for both Homebrew and MacPorts. Installing Yarn through npm i -g yarn on those non-Windows operating systems will have Yarn spurt out a warning recommending users to install Yarn through the for-their-operating-system recommend method (last I checked) on every command you fire up with it.

I therefore strongly suggest referencing the Yarn installation page for readers that are not using Windows: https://yarnpkg.com/lang/en/docs/install/

Favna commented Dec 20, 2017

Concerning this line:

Install Yarn globally: npm i -g yarn

Yarn themselves recommend installing Yarn through other means than the node package manager for Linux and MacOS with the former varying on the distro and the latter having options for both Homebrew and MacPorts. Installing Yarn through npm i -g yarn on those non-Windows operating systems will have Yarn spurt out a warning recommending users to install Yarn through the for-their-operating-system recommend method (last I checked) on every command you fire up with it.

I therefore strongly suggest referencing the Yarn installation page for readers that are not using Windows: https://yarnpkg.com/lang/en/docs/install/

@felixfbecker

This comment has been minimized.

Show comment
Hide comment
@felixfbecker

felixfbecker Dec 20, 2017

Contributor

@Favna is there any reason why it should be done that way?

Contributor

felixfbecker commented Dec 20, 2017

@Favna is there any reason why it should be done that way?

@Favna

This comment has been minimized.

Show comment
Hide comment
@Favna

Favna Dec 20, 2017

@felixfbecker I have too little experience with the aforementioned non-Windows environments to be able to properly answer that, therefore I can only assume that if there wasn't a compelling reason to do so then Yarn wouldn't be recommending its users to install it through their recommend ways.

Favna commented Dec 20, 2017

@felixfbecker I have too little experience with the aforementioned non-Windows environments to be able to properly answer that, therefore I can only assume that if there wasn't a compelling reason to do so then Yarn wouldn't be recommending its users to install it through their recommend ways.

@felixfbecker

This comment has been minimized.

Show comment
Hide comment
@felixfbecker

felixfbecker Dec 20, 2017

Contributor

@Favna I could see how they don't want to be "coupled" in any way to npm, i.e. no want to require npm to install yarn, as they are a competitor to npm. It always felt weird using npm to install bower. That is definitely not a reason to "strongly suggest" stop using npm...

Contributor

felixfbecker commented Dec 20, 2017

@Favna I could see how they don't want to be "coupled" in any way to npm, i.e. no want to require npm to install yarn, as they are a competitor to npm. It always felt weird using npm to install bower. That is definitely not a reason to "strongly suggest" stop using npm...

@Stanzilla

This comment has been minimized.

Show comment
Hide comment
@Stanzilla

Stanzilla Dec 20, 2017

As long as there is no functioning way to self-update Yarn, people will always prefer the npm method, imo.

Stanzilla commented Dec 20, 2017

As long as there is no functioning way to self-update Yarn, people will always prefer the npm method, imo.

@MonsieurMan

This comment has been minimized.

Show comment
Hide comment
@MonsieurMan

MonsieurMan Dec 26, 2017

@joaomoreno, you should edit this part like so as @octref mentionned :

What about npm run TASK?

You can still do that. No problem.
Or run yarn <task> if the taskname is not conflicting with any native yarn command.
It'll save time to everybody 😄

MonsieurMan commented Dec 26, 2017

@joaomoreno, you should edit this part like so as @octref mentionned :

What about npm run TASK?

You can still do that. No problem.
Or run yarn <task> if the taskname is not conflicting with any native yarn command.
It'll save time to everybody 😄

@t-sauer

This comment has been minimized.

Show comment
Hide comment
@t-sauer

t-sauer Jan 23, 2018

@felixfbecker you can find their reasons under „Install with npm“ under the alternatives tab on the installation docs

t-sauer commented Jan 23, 2018

@felixfbecker you can find their reasons under „Install with npm“ under the alternatives tab on the installation docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment