【问题标题】:firebase deploy gives a "path" errorfirebase deploy 给出“路径”错误
【发布时间】:2018-10-12 01:02:00
【问题描述】:

使用

启动我的 firebase 应用程序后
firebase init

我尝试用

部署它
firebase deploy

但我收到此错误

    === Deploying to 'fugis-auto-services-website'...

i  deploying database, storage, functions, hosting

Error: An unexpected error has occurred.

所以我查看了 firebase-debug.log,它是这么写的

Tue May 01 2018 19:52:19 GMT-0500 (CDT)
[debug] [2018-05-02T00:52:19.967Z] <<< HTTP RESPONSE 200
[info] 
[info] === Deploying to 'fugis-auto-services-website'...
[info] 
[info] i  deploying database, storage, functions, hosting
[debug] [2018-05-02T00:52:20.266Z] TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
    at assertPath (path.js:39:11)
    at Object.join (path.js:1157:7)
    at Config.path (/Users/vanessaflores/.nvm/versions/node/v10.0.0/lib/node_modules/firebase-tools/lib/config.js:166:37)
    at /Users/vanessaflores/.nvm/versions/node/v10.0.0/lib/node_modules/firebase-tools/lib/deploy/lifecycleHooks.js:68:38
    at _chain (/Users/vanessaflores/.nvm/versions/node/v10.0.0/lib/node_modules/firebase-tools/lib/deploy/index.js:26:38)
    at /Users/vanessaflores/.nvm/versions/node/v10.0.0/lib/node_modules/firebase-tools/lib/deploy/index.js:29:14
    at process._tickCallback (internal/process/next_tick.js:178:7)
[error] 
[error] Error: An unexpected error has occurred.

我不知道如何继续。

【问题讨论】:

  • 你的firebase.json是什么样的?
  • 遇到同样的问题。

标签: firebase firebase-hosting firebase-cli


【解决方案1】:

我在没有传递实际文档路径的情况下使用了诸如 onCreate 或 onUpdate 之类的 Firestore 回调。

functions.firestore
.document()
.onCreate()

把它变成

functions.firestore
.document('collection/doc')
.onCreate()

【讨论】:

    【解决方案2】:

    回答为时已晚,但将来可能会对某人有所帮助,我遇到了同样的问题,我添加了@Gleb 提到的公用文件夹,并且在您的 firebase.json 中,您还需要指定公用文件夹,如下所示:

    {
    "hosting": {
    "public": "public",
    "rewrites": [
      {
        "source": "**",
        "function": "helloWorld"
      }
    ]
    }
    }
    

    【讨论】:

    • 谢谢!托管部署似乎需要“公共”参数。请注意,您还必须创建一个实际的文件夹,即使它可以是空的。
    • 任何想法为什么在部署时会出现此错误:github.com/QuantumInformation/svelte-fullstack-starter/blob/… “路径”参数必须是字符串类型。在 validateString (internal/validators.js:125:11) 处接收到未定义的类型
    • 似乎是真的,我们需要在托管对象中公开条目。如果是这样的话,有什么办法只能单独重写云功能?
    【解决方案3】:

    与我使用托管部分设置标题相同的问题,public 属性是必要的!如果你不定义它,你会遇到这个问题

    【讨论】:

      【解决方案4】:

      我遇到了同样的问题,所以在调试 2 小时后,我通过使用命令 npm install npm-conf@1.1.0 将 npm-conf 降级到 1.1.0 解决了这个问题

      【讨论】:

        【解决方案5】:

        我的问题最终是我将我的 macOS 更新到了 High Sierra 10.13.4 并且不知何故搞砸了我的 nvm 路径。我不得不更新 nvm 并重新安装了 Firebase,现在一切似乎都正常了。

        【讨论】:

          【解决方案6】:

          我可以通过重新初始化 firebase 函数来解决这个问题:

          firebase init functions
          

          您可能需要先更新您的 firebase-tools:

          npm install -g firebase-tools
          

          并备份您现有的函数目录。

          【讨论】:

          • 不知道初始化可以单独为函数、firestore 等完成。firebase init functions 运行了例程并为我修复了它
          猜你喜欢
          • 2019-03-30
          • 2020-12-04
          • 1970-01-01
          • 2021-05-12
          • 2021-10-31
          • 2022-06-16
          • 1970-01-01
          • 2018-06-27
          相关资源
          最近更新 更多