Skip to content
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

Cannot find module 'grpc' #130

Closed
Lacka90 opened this issue Nov 9, 2017 · 19 comments
Closed

Cannot find module 'grpc' #130

Lacka90 opened this issue Nov 9, 2017 · 19 comments
Assignees

Comments

@Lacka90
Copy link

Lacka90 commented Nov 9, 2017

After I added the firebase functions and trying to deploy an angular app into firebase I got this:

i  deploying firestore, functions, hosting
i  firestore: checking firestore.rules for compilation errors...
✔  firestore: rules file firestore.rules compiled successfully
i  functions: ensuring necessary APIs are enabled...
i  runtimeconfig: ensuring necessary APIs are enabled...
✔  runtimeconfig: all necessary APIs are enabled
✔  functions: all necessary APIs are enabled
i  firestore: uploading rules firestore.rules...
i  functions: preparing functions directory for uploading...

Error: Error parsing triggers: Cannot find module 'grpc'

Try running "npm install" in your functions directory before deploying.

Are there any resolution or workaround to this?

My env is
node 8.9.0
npm 5.5.1
firebase 3.14.0

@justinrosenthal
Copy link
Contributor

Just to confirm, did you run npm install from inside the functions directory?

Additionally, it's recommended that you run Node v.6.11.1 because that's the version which will be running your code in the Cloud Functions environment, as mentioned here.

@Lacka90
Copy link
Author

Lacka90 commented Nov 9, 2017

Yes I made npm install in the functions directory.

I tried again with node v6.11.1. but the same error message appears :(
I'm trying to follow the tutorial to make an universal angular app:
https://hackernoon.com/deploy-angular-universal-w-firebase-ad70ea2413a1

@justinrosenthal
Copy link
Contributor

What's in your package.json? Does the npm install succeed?

@mbifulco
Copy link

I'm was runninginto a similar error trying to run firebase functions locally, and I found something that may address this for you @Lacka90.

In my case, I was running n to select version 6.11.1 of npm, but typically I use yarn to manage my projects (as well as higher versions of node in other projects).

I suspect that was a part of the problem, since I may have installed dependencies with yarn install at some point out of habit.

The specific error I was getting was:

Cannot find module '/[...local path...]/functions/node_modules/grpc/src/node/extension_binary/node-v48-darwin-x64/grpc_node.node'

If I inspect the missing path above, it's got node-v57-darwin-x64/grpc_node.node (note v57 vs the v48 that the firebase call is looking for.

To fix
I cleared my node_modules directory, and reinstalled using npm install to be sure everything came from npm, and not yarn. This installed the correct version of grpc, and I no longer had that error to deal with.

@laurenzlong
Copy link
Contributor

Thanks for sharing the fix!

@adamduren
Copy link

@laurenzlong I can confirm that the above fix does not work for me.

@adamduren
Copy link

For me this is happening because a npm module that I use relies on the firebase client library. It appears the firebase client library has a side-effect of breaking firebase-admin.

@laurenzlong laurenzlong reopened this Nov 14, 2017
@laurenzlong laurenzlong self-assigned this Nov 14, 2017
@adamduren
Copy link

I've been working on debugging this one as well and I believe it's related to firebase/firebase-tools#442 and possibly firebase/firebase-js-sdk#221 (comment) as per the comment.

@factedu
Copy link

factedu commented Nov 24, 2017

This worked form me (I reinstalled firebase tool and update the firebase-functions):-
npm install -g firebase-tools
npm install firebase-functions@latest --save

@connormckelvey
Copy link

connormckelvey commented Nov 25, 2017

@factedu I tried what you suggested. Did not work for me :(

@laurenzlong
Copy link
Contributor

@connormckelvey What versions of npm are you using? Can you try updating it and see if it resolves the issue?

@ankush2394
Copy link

I have tried npm versions 5.4 and 3.2 and node versions 8.9.2 and 6.9 and the problem is the same .
"Cant find grpc module ".
Tried every possible written solutions.
None worked for me as well.

@stefan-matcovici
Copy link

stefan-matcovici commented Jan 6, 2018

I am using npm 5.5.1 and had problems with grpc at deploying. I installed firebase-admin@~5.5.0 and everything seems to work normally now.

@ankush2394
Copy link

Will have to try it out as now i am working on mac os sierra.

@laurenzlong
Copy link
Contributor

This is the repo for grpc node: https://github.com/grpc/grpc-node. Please file specific installation issues there.

In my experience, grpc installation issues can usually be resolved by a combination of updating npm and reinstalling, but the grpc team may be able to offer more specific advice.

@laurenzlong
Copy link
Contributor

We are capturing all grpc installation issues experienced in Firebase CLI in grpc/grpc-node#121

@JavaidAhmad
Copy link

Issue Resolved!
In my case, I faced the same issue...
I installed
npm install -g firebase@4.6.2

and removed cap ^ in package.json before firebase version.
#hopeItWillWorkForYou

@shraiysh
Copy link

Solved! I had a very similar error and it worked for me when I used
npm install grpc@latest --save
in the functions directory.
In my case it could not find a specific file and showed the error as
Error: Error parsing triggers: Cannot find module '<path_to_my_firebase_functions>/node_modules/grpc/src/node/extension_binary/node-v57-linux-x64-glibc/grpc_node.node'

@shaneosullivan
Copy link

In my case I had a package-lock.json file with some items that were no longer needed. I did

rm package-lock.json
rm -rf node_modules
npm install

and the problem went away

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

No branches or pull requests