Using Yarn with Meteor
Category : Meteor
Installing Yarn globally with the
meteor install yarn -g command doesn’t add the
meteor yarn command, as it does on other OS’s. If you use Yarn outside of
meteor yarn, you have to make sure they are in the same Node environment, or you may run into errors like this…
When installing chimp (which then builds bcrypt) using Yarn and Node 7 results in a hung process with output like this:
[3/4] Linking dependencies... [4/4] Building fresh packages... [1/4] ? bcrypt: gyp info using email@example.com | win32 | x64 [2/4] ? fibers: firstname.lastname@example.org | win32 | x64 [3/4] ? phantomjs-prebuilt: Found PhantomJS at C:\Projects\LandTen\applicationFiles\node_modules\phantomjs-prebuilt\lib\ [-/4] ? waiting...
that quickly changes to this:
[3/4] Linking dependencies... [-/4] ? waiting... [2/4] ? fibers: gyp info spawn args '-Goutput_dir=.' ] [-/4] ? waiting... [-/4] ? waiting...
You can see in that first block that node-gyp is using Node 7.7.1. But the version of Node that Meteor is using (I’m running Meteor 220.127.116.11) is Node v4.73.
So what? Big deal! It is a big deal. Any npm packages that require building binaries will require a specific version of node. If you attempt to use a different version of node, they will be built using the wrong C++ files. So I could abandon Yarn, or I could force Yarn to use Node v4.x.
If you’re using Chocolatey, and you should be, you’ll have to uninstall the wrong Node/s and install the right one. Install the same major version of Node on your machine that Meteor is using. Chocolatey offers version 4.6.1. You’ll also have to install Yarn with the ignore-dependencies flag, so Choco won’t automatically install the latest version of node.
choco uninstall yarn nodejs-lts nodejs.install choco install nodejs.install --version 4.6.1 choco install yarn --ignore-dependencies
and Bob’s your uncle