如何通过Firebase托管在Firebase上托管Node.js Web应用程序(包含多个文件夹)?

时间:2019-03-04 03:35:14

标签: node.js firebase express firebase-hosting

我已经完成了所有的Firebase托管过程。在我的firebase帐户中,我可以使用实时数据库,firestore,托管和功能。当我尝试在Firebase上部署Web应用程序时,出现此错误:

=== 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

**我在此处附加了我的项目文件夹和firebase.json文件的屏幕截图:

 {
      "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

1 个答案:

答案 0 :(得分:0)

firebase.json中,将其配置为在部署之前执行lint npm-script

npm --prefix ./functions/ run lint

这将导致以下错误。

  

npm错误!缺少脚本:皮棉

您应确保package.json中的functions定义了lint脚本。