From the docs I concluded that it's not necessary to have local pckgs in node_modules installed for GCS to operate: it should install them in the instance based on package.json. So, I deleted node_modules coz it seemed that it uploads and takes some time to do that. However I get an err. Anyone else has this?
i deploying functions
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 functions: preparing functions directory for uploading...
Error: Error parsing triggers: Cannot find module 'firebase-functions'
Try running "npm install" in your functions directory before deploying.
The Firebase CLI executes your code locally in order to parse the triggers, so you must have node_modules locally in order to deploy. However, when we pack up the functions directory to upload we ignore node_modules so whether it's there or not will not impact deploy time.
what is the solution?
Hi @jjhesk , run the following inside of your functions directory:
npm install
firebase deploy
I ran into this and struggled with it for a bit so just to add some help to others that might run across this and not see the obvious answer.
If you're using some kind of automated pipeline then you will likely need to specifically add the cd functions && npm install && cd - to the runner. Below is an example .gitlab-ci.yml that I use for for a gitlab polymer project.
I think I got hung up on this because I didn't have to do that step locally when I first setup the project. Likely firebase init just did it for me.
image: node:6
before_script:
- npm install -g firebase-tools
- npm install -g bower
- npm install -g polymer-cli
cache:
paths:
- node_modules/
- functions/node_modules/
- bower_components/
deploy_to_firebase:
stage: deploy
environment: Production
only:
- master
script:
# cd to the functions directory and `npm install` so firebase-functions is installed
- cd functions && npm install && cd -
- bower install --allow-root
- polymer build
- firebase use --token $FIREBASE_DEPLOY_KEY
- firebase deploy -m "Pipeline $CI_PIPELINE_ID, build $CI_BUILD_ID" --non-interactive --token $FIREBASE_DEPLOY_KEY
laurenzlong solution is correct, but watch out!
You'll have more than one package.json in your project. I missed her point about the functions directory the first time I read it.
run the following inside of your functions directory:
I messed up and ran npm install googleapis --save in the Project Directory. Be sure to run npm install in the functions directory::
project\functions
Would you like to help me ?
I am also facing the same problem and I run this npm install in functions directory but this response!


@badarshahzad It looks like you're running into npm permission issues (this is not a problem with firebase-tools, but your local setup). https://docs.npmjs.com/getting-started/fixing-npm-permissions will hopefully help you fix it.
thank you @laurenzlong the problem is solved.
Issue: yesterday night the problem was the android studio projects in root directory and I created the firbase-funcitons directory along with my android project. I just create new dir on desktop and repeat all steps and it starts working. :100:
So sometimes this happens if you have your cloud functions in one dir, and the rest of your app in another. Make sure to go into /functions and run npm i as your base npm install may have work but GCF has it's own. Not sure if thats helpful
Hi All,
Error: Error parsing triggers: Cannot find module 'firebase-functions'
Try running "npm install" in your functions directory before deploying.
C:......\functions>npm i
npm WARN [email protected] requires a peer of firebase-admin@~5.6.0 but none is installed. You must install peer dependencies yourself.
up to date in 3.302s
C:\Users\Owner..\mycloudfunctionapp\functions>firebase deploy --only functions
=== Deploying to 'mycloudfunctionapp'...
i deploying functions
i functions: ensuring necessary APIs are enabled...
Error: Error parsing triggers: Cannot find module 'firebase-functions'
Try running "npm install" in your functions directory before deploying.
C:\Users\Owner\Desktop\mycloudfunctionapp\functions>npm install
npm WARN [email protected] requires a peer of firebase-admin@~5.6.0 but none is installed. You must install peer dependencies yourself.
up to date in 12.474s
โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ โ
โ Update available 5.5.1 โ 5.6.0 โ
โ Run npm i -g npm to update โ
โ โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
C:\Users\Owner\Desktop\mycloudfunctionapp\functions>npm i -g npm
C:\Users\Owner\AppData\Roaming\npm\npx -> C:\Users\Owner\AppData\Roaming\npmnode_modules\npm\bin\npx-cli.js
C:\Users\Owner\AppData\Roaming\npm\npm -> C:\Users\Owner\AppData\Roaming\npmnode_modules\npm\bin\npm-cli.js
C:\Users\Owner\Desktop\mycloudfunctionapp>firebase deploy
=== Deploying to 'mycludfunctionapp'...
i deploying database, functions, hosting
i database: checking rules syntax...
Error: Error parsing triggers: Cannot find module 'firebase-functions'
Any advice and suggestions are highly appreciated.
thanks
@eGlobeBizCom I can't tell what's going on here and it seems quite specific to your set up, can you file a support ticket and provide as much details as you can about what's in your package.json and what's in your functions/node_modules
@mbleigh
Hi I know this is not the right place, but we got an issue as in the link below suddenly today.
@google-cloud/firestore node library refers a specific version of nanomatch which has a bug.
Firebase functions for firestore stops working due to this from today's lunch time (in JST). As you mentioned above, updating node modules in our local project doesn't fix the issues, since our local node_modules are not the ones actually used after deploy. Can you fix the issue?
@mbleigh
The issue looks registered here
https://github.com/firebase/firebase-admin-node/issues/298
Most helpful comment
I ran into this and struggled with it for a bit so just to add some help to others that might run across this and not see the obvious answer.
If you're using some kind of automated pipeline then you will likely need to specifically add the
cd functions && npm install && cd -to the runner. Below is an example.gitlab-ci.ymlthat I use for for a gitlab polymer project.I think I got hung up on this because I didn't have to do that step locally when I first setup the project. Likely
firebase initjust did it for me.