Yarn, Windows, and bcrypt

I noticed on Mac and Linux, it’s possible to run meteor npm i -g yarn to get yarn support (meteor yarn). On Windows, this is not possible, however. And regular old yarn works great as far as installing packages, though compiled packages are hit or miss.

In the case of bcrypt, Meteor doesn’t like the way yarn builds it. After running yarn add bcrypt and then meteor, I get:

Should we just not use meteor + yarn on Windows for the time being?

I get the same with plain NPM - very annoying! In all honesty I couldn’t care less if bcrypt is a bit slower in JS.

Well, with npm, that behavior is on all platforms. When installing certain packages like bcrypt that need to be compiled, you should always use meteor npm install so it builds for the correct version of node.

Maybe that’s just the issue here, that plain old yarn isn’t building it in a way Meteor likes.

1 Like

I found that the issue is in that plain npm/yarn get packages for the version of node that is globally installed, which if that doesn’t matches to meteor version of node (4.x.x), then it will get the wrong version of the package.

You might want to try to specify engines in your package.json. Not sure if that will work, but it might be less of a pain than changing your global version of node.

You can work around this by using yarn to install all your packages, and then using meteor npm install bcrypt --save to get the right version of that, though you may have to do it pretty frequently after adding/removing packages with yarn.

I’m not sure why you can’t install yarn inside meteor on Windows though. Seems like a bug.

I haven’t tried it, but you may also be able to use nvm or another node version switcher to switch your global node.js version to match whatever you have in meteor (find out with meteor node -v). After that yarn may install the correct version of bcrypt - but as I said, I haven’t tried it.