首页 文章

Firebase部署错误从非零退出代码开始(项目路径中的空间)

提问于
浏览
18

我最近遇到了firebase deploy命令的问题 . 在firebase部署命令之后,除了firebase(存储,数据库等)之外所有其他人都被部署了所以我决定重新安装firebase来解决这个问题,但重新安装后我的问题变大了 . 现在没有部署它们,并出现以下错误:

i deploying database, functions
Running command: npm --prefix $RESOURCE_DIR run lint
npm ERR! path C:\Users\faruk\Google Drive\Android\firebase\1\$RESOURCE_DIR\package.json
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\faruk\Google Drive\Android\firebase\1\$RESOURCE_DIR\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\faruk\AppData\Roaming\npm-cache\_logs\2018-01-24T18_21_34_878Z-debug.log

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

经过一番研究,我看到了一些关于这个改变建议的话题

$RESOURCE_DIR to %RESOURCE_DIR%

在Windows系统(我使用Windows 10顺便说一句) . 所以,我编辑了firebase.json文件,该文件位于我的函数文件夹的上一级 . 像这样 . (我不知道这是否是我应该编辑的正确文件)

"database": {
    "rules": "database.rules.json"
  },
  "functions": {
    "predeploy": [
      "npm --prefix %RESOURCE_DIR% run lint"
    ]
  }
}

但在这次编辑之后,我开始收到这样的另一条错误消息 .

i  deploying database, functions
Running command: npm --prefix %RESOURCE_DIR% run lint

Usage: npm <command>

where <command> is one of:
    access, adduser, bin, bugs, c, cache, completion, config,
    ddp, dedupe, deprecate, dist-tag, docs, doctor, edit,
    explore, get, help, help-search, i, init, install,
    install-test, it, link, list, ln, login, logout, ls,
    outdated, owner, pack, ping, prefix, profile, prune,
    publish, rb, rebuild, repo, restart, root, run, run-script,
    s, se, search, set, shrinkwrap, star, stars, start, stop, t,
    team, test, token, tst, un, uninstall, unpublish, unstar,
    up, update, v, version, view, whoami

npm <command> -h     quick help on <command>
npm -l           display full usage info
npm help <term>  search for help on <term>
npm help npm     involved overview

Specify configs in the ini-formatted file:
    C:\Users\faruk\.npmrc
or on the command line via: npm <command> --key value
Config info can be viewed via: npm help config

npm@5.6.0 C:\Program Files\nodejs\node_modules\npm

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

任何建议表示赞赏 . 提前致谢 .

5 回答

  • 1

    对我来说,问题是(我推测),因为 firebase 找不到脚本 .

    没用了:

    {
      "hosting": {
        "predeploy": "predeploy.sh",
        ...
    }
    
    Running command: predeploy.sh
    events.js:160
          throw er; // Unhandled 'error' event
          ^
    
    Error: spawn predeploy.sh ENOENT
        at exports._errnoException (util.js:1020:11)
        at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
        at onErrorNT (internal/child_process.js:367:16)
        at _combinedTickCallback (internal/process/next_tick.js:80:11)
        at process._tickCallback (internal/process/next_tick.js:104:9)
        at Module.runMain (module.js:606:11)
        at run (bootstrap_node.js:389:7)
        at startup (bootstrap_node.js:149:9)
        at bootstrap_node.js:504:3
    
    Error: hosting predeploy error: Command terminated with non-zero exit code1
    

    做了工作:(注意./)

    {
      "hosting": {
        "predeploy": "./predeploy.sh",
        ...
    }
    
  • 13

    实际发生的是,在Windows中, firebase.json 默认包含以下内容:

    "predeploy": [
      "npm --prefix \"$RESOURCE_DIR\" run lint"
    ]
    

    将其修改为:

    "predeploy": [
      "npm --prefix \"%RESOURCE_DIR%\" run lint"
    ]
    

    它对我有用,希望它适合你 .

  • 0

    我在Windows中遇到了同样的问题 . 我做的是我复制了 functions 文件夹中的所有文件并将其传递到 %RESOURCE_DIR% 文件夹,然后运行Firebase部署并成功部署 .

  • 0

    该错误源于您在项目路径中的某个位置(“Google Cloud 端硬盘”):

    C:\Users\faruk\Google Drive\Android\firebase\1\$RESOURCE_DIR\package.json
    

    不幸的是,这让npm命令行感到困惑,并且它将这个作为由该空格分隔的两个参数 .

    通常情况下,我希望能够在整个事情周围放置引号,以防止空间被解释 . 所以我尝试了这个:

    "predeploy": [
      "npm --prefix \"%RESOURCE_DIR%\" run lint"
    ]
    

    它对我有用 .

    我将在内部跟进Firebase团队有关此问题的信息,以及需要对Windows进行更改的事实 .

  • 36

    在firebase.json中将$ RESOURCE_DIR更改为%RESOURCE_DIR%之后,这对我有用

    {
      "functions": {
        "predeploy": [
          "npm --prefix \"%RESOURCE_DIR%\" run lint",
          "npm --prefix \"%RESOURCE_DIR%\" run build"
        ]
      }
    }
    

相关问题