Search code examples
node.jsfirebaseexpressfirebase-hosting

how to host node.js web app(containing multiple folders) on firebase through firebase hosting?


I have completed all the firebase hosting process. In my firebase account, I can use realtime database, firestore, hosting and functions. When I was trying to deploy my web app on firebase, I got this error :

=== Deploying to 'remonet-f20c4'...

i  deploying database, storage, firestore, functions, hosting
Running command: npm --prefix "%RESOURCE_DIR%" run lint
npm ERR! missing script: lint

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\H P\AppData\Roaming\npm-cache\_logs\2019-02-28T11_03_51_407Z-debug.log
events.js:167
      throw er; // Unhandled 'error' event
      ^

Error: spawn npm --prefix "D:\Mangesh\ReMoNet\functions" run lint ENOENT
    at notFoundError (C:\Users\H P\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:6:26)
    at verifyENOENT (C:\Users\H P\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:40:16)
    at ChildProcess.cp.emit (C:\Users\H P\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:27:25)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:240:12)
Emitted 'error' event at:
    at ChildProcess.cp.emit (C:\Users\H P\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:30:37)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:240:12)

Error: functions predeploy error: Command terminated with non-zero exit code1

**I have screenshot of my project folders attached and firebase.json file here :

 {
      "database": {
        "rules": "database.rules.json"
      },
      "functions": {
        "predeploy": [
          "npm --prefix \"%RESOURCE_DIR%\" run lint",
          "npm --prefix ./functions/ run lint",
          "npm --prefix ./functions/ run build"
        ],
        "source": "functions"
      },
      "hosting": {
        "public": "public",
        "ignore": [
          "firebase.json",
          "**/.*",
          "**/node_modules/**"
        ]
      },
      "firestore": {
        "rules": "firestore.rules",
        "indexes": "firestore.indexes.json"
      },
      "storage": {
        "rules": "storage.rules"
      }
    }

Project Folders view


Solution

  • In firebase.json it is configured to execute the lint npm-script before deploying.

    npm --prefix ./functions/ run lint
    

    This is resulting in the following error.

    npm ERR! missing script: lint

    You should make sure that the package.json in functions has a lint script defined.