Reputation: 321
When I am trying to deploy a firebase project it shows an error message 'cannot find module firebase-functions' in npm console.The steps(node commands) I have done are:
and finally where I stucked is
4. firebase deploy
Please help me.
Upvotes: 29
Views: 25788
Reputation: 778
I ran into this same issue scratching my head since I could clearly see firebase-functions
in my package.json and it was definitely installed.
Then I remembered that I'm deploying (inherently production), and firebase-functions
was in my devDependencies section of package.json instead of dependencies.
In case someone runs into this same issue, double check that firebase-functions
is in dependencies as it won't be included in the resulting bundle or deployment otherwise. In my case, I needed to explicitly add it to my functions/package.json.
E.g. -> Move a module from devDependencies to dependencies in npm package.json
Upvotes: 0
Reputation: 4316
I'm using @nrwl/nx monorepo and moved /functions to /apps and all my node pages are in the root project folder. What worked for me is to replace the double quotes with single quotes
import * as functions from "firebase-functions";
to
import * as functions from 'firebase-functions';
Upvotes: 0
Reputation: 7631
This may happen if you have requires with wrong cases!
The firebase function file system seems to be case sensitive.
So if you do
const { myStuff } = require('./mystuff');
but the file is actually named myStuff.js
, it may very well work locally, but fails on build
Upvotes: 2
Reputation: 2718
It's simple! If it says can't find module firebase-functions then install them.
npm install firebase-functions
Upvotes: 12
Reputation: 466
you should install node_modules in the functions directory in your project
cd functions
npm install
then run firebase deploy
Upvotes: 11
Reputation: 228
Could be that you didn't follow the instructions provided when running "firebase init". You should press space and then enter in order to select the option you want - possibly that's why there was no functions folder.
Upvotes: 6