Skip to content
This repository has been archived by the owner on May 15, 2019. It is now read-only.

docs: Angular + Yarn + Firebase needs special consideration #304

Open
jorroll opened this issue Jan 19, 2019 · 1 comment
Open

docs: Angular + Yarn + Firebase needs special consideration #304

jorroll opened this issue Jan 19, 2019 · 1 comment

Comments

@jorroll
Copy link

jorroll commented Jan 19, 2019

This is a proposed documentation improvement

I would submit this as a PR to the wiki "detailed installation instructions" docs, but I can't see a way of editing a wiki page.

When attempting to use the @google-cloud/functions-emulator with firebase-tools on a system using nvm which also has multiple version of node, so far as I can tell, you should use npm and not yarn to both install @google-cloud/functions-emulator globally as well as install firebase-tools globally.

I think this is because nvm segregates npm global installs by node version, while yarn global installs are shared between all node versions. Thus, if you install multiple packages globally via yarn which require different, incompatible versions of node, you're going to run into an error.

As an example, when using nvm in an Angular v7 monorepo which contains a project representing firebase cloud functions, the firebase functions package.json will require node v6.x while the rest of the repo will require node v8.x. If you install v7 of @angular/cli globally via yarn, it will require you to be using node >8.x. If you switch to node v6.x using nvm use and attempt to then install @google-cloud/functions-emulator globally, yarn will throw an error because angular/cli does not work with node v6 (and yarn shares global packages between node versions--or, probably more accurately, nvm doesn't seem to segregate yarn global packages like it does npm ones.).

Additionally, when emulating firebase cloud functions using @google-cloud/functions-emulator and firebase functions:shell, the firebase-tools global install expects the @google-cloud/functions-emulator global install to be installed using the same package manager (i.e. both firebase-tools and @google-cloud/functions-emulator seem to need to be installed globally using the same package manager, either both npm or both yarn).

  • For example: if you do
    yarn global add firebase-tools
    nvm use v6.16.0
    npm install -g @google-cloud/functions-emulator
    firebase functions:shell
    
    an error will be thrown. But everything works fine if both firebase-tools and @google-cloud/functions-emulator are installed using npm.

So, in conclusion, to use @google-cloud/functions-emulator with nvm, users should first run yarn global remove @google-cloud/functions-emulator firebase-tools and instead use nvm use to switch to the desired version of node and then run npm install -g @google-cloud/functions-emulator firebase-tools (if using node v6.x) or just npm install -g firebase-tools if using another version of node. As a reminder, users will need to reinstall firebase-tools globally for each version of node they have on their system.

I'm guessing angular + yarn + firebase is a common enough combo that it would be worthwhile to add a comment linking to more information in the readme.

@dungahk
Copy link

dungahk commented Mar 10, 2019

Actually, the emulator should support Node 8 by now, but this package hasn't got a release for a while now.

Check the package.json engines property: https://github.com/GoogleCloudPlatform/cloud-functions-emulator/blob/master/package.json#L8
That was done on #287

But this is the latest version released: https://github.com/GoogleCloudPlatform/cloud-functions-emulator/blob/1.0.0-beta.5/package.json#L8

All we need is a new version released and that issue should be solved.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants