skip to Main Content

I keep seeing this error when I run firebase deploy --only functions in my functions directory. I get this:

Error: Cannot find module 'diagnostics'
Require stack:
- C:UsersJohnsonAppDataRoamingnvmv12.16.1node_modulesfirebase-toolsnode_moduleswinstonlibwinstonexception-handler.js
- C:UsersJohnsonAppDataRoamingnvmv12.16.1node_modulesfirebase-toolsnode_moduleswinstonlibwinstonlogger.js
- C:UsersJohnsonAppDataRoamingnvmv12.16.1node_modulesfirebase-toolsnode_moduleswinstonlibwinstoncreate-logger.js
- C:UsersJohnsonAppDataRoamingnvmv12.16.1node_modulesfirebase-toolsnode_moduleswinstonlibwinston.js
- C:UsersJohnsonAppDataRoamingnvmv12.16.1node_modulesfirebase-toolsliblogger.js
- C:UsersJohnsonAppDataRoamingnvmv12.16.1node_modulesfirebase-toolslibindex.js
- C:UsersJohnsonAppDataRoamingnvmv12.16.1node_modulesfirebase-toolslibbinfirebase.js

Here’s the content of my package.json:

{
  "name": "functions",
  "description": "Cloud Functions for Firebase",
  "engines": {
    "node": "10"
  },
  "scripts": {
    "lint": "eslint .",
    "serve": "firebase serve --only functions",
    "shell": "firebase functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "dependencies": {
    "@woocommerce/woocommerce-rest-api": "^1.0.1",
    "algoliasearch": "^4.0.3",
    "firebase-admin": "^8.6.0",
    "firebase-functions": "^3.6.1",
    "moment": "^2.24.0",
    "node-mailjet": "^3.3.1"
  },
  "devDependencies": {
    "eslint": "^5.12.0",
    "eslint-plugin-promise": "^4.0.1"
  },
  "private": true
}

I recently (couple weeks ago) updated my functions directory from Node 8 to Node 10, not sure if that is related to this issue. I’ve tried deleting node_modules folder and also package-lock.json and run npm install. I’ve also tried running npm install -g firebase-tools and then firebase deploy --only functions, but error still persists. Please, what to do?

2

Answers


  1. Chosen as BEST ANSWER

    I have sorted this out. I simply uninstalled firebase-tools globally from npm and reinstalled. The issue was probably a side-effect of running Windows restore on my PC (Thank you Windows!)


  2. There is a simple solution that works for many of these node/npm problems. First, install yarn using the following command:
    npm install -g yarn

    Then use yarn to install all the node modules for your project example:

    yarn add your_node_module

    or

    yarn add global your_node_modue (for global installation)

    if for example you want to use firebase commands, and it gives an error or says "command not found", then do this:

    yarn firebase init

    yarn firebase deploy

    etc…

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search