1

When I run firebase deploy I get this error:

Error parsing triggers: Cannot find module 'firebase-admin'

Here's my code:

const functions = require('firebase-functions');

const admin = require('firebase-admin');

My package.json is:

  {
  "name": "functions",
  "description": "Cloud Functions for Firebase",
  "dependencies": {
    "firebase-admin": "^5.2.1",
    "firebase-functions": "^0.6.2",
    "request": "^2.83.0"
  },
  "private": true
}

Here are my global node modules:

npm list -g --depth=0                                       
/Users/TDK/.nvm/versions/node/v6.11.2/lib
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

I don't have firebase-admin installed locally: enter image description here

Running npm install, npm install firebase-admin, and npm install --save firebase-admin in the local functions directory return this error message:

npm ERR! Cannot read property '0' of undefined

I'm using npm version 5.4.2.

I changed ~5.2.1 to ^5.2.1.

I removed package-lock.json but that didn't fix the problem.

I get the same error message when I do this in the project root directory and in the functions directory.

Any suggestions?

3 Answers 3

1
rm -rf node_modules/

npm install

This did the trick for me.

Sign up to request clarification or add additional context in comments.

Comments

0

What worked was to make a fresh directory and set up the "Hello world" tutorial from the Firebase documentation. This creates a node_modules directory that includes firebase-admin. I then swapped the new node_modules directory with the old directory and it worked.

The problem appears to have been that I had firebase-admin installed globally so npm install wouldn't install it locally in my functions directory, but firebase deploy can't find global Node modules, it has to have local Node modules. That's my guess.

1 Comment

Seems not to be the problem. Here, the firebase-admin is right there in node_modules and not installed globally, but the same error is reported on deploy
0

remove the node_modules folder or rename it. After that, edit your package.json file and set the packages versions to "*" to install the latest version of each one.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.