Cloud Functions 不是从命令行部署的

Cloud Functions not Deploying from the Command Line

我在部署云函数时遇到问题。我移动到包含我的函数的 android 项目的根目录并使用 firebase deploy 命令,我得到这个输出:

Last login: Mon Feb 26 23:36:02 on ttys000
joels-MacBook-Pro:~ joeljohnson$ cd /Users/joeljohnson/Documents/Computer\ Science/Android/GradleFinalProject 
joels-MacBook-Pro:GradleFinalProject joeljohnson$ firebase deploy

=== Deploying to 'gradlefinalproject-42f02'...

i  deploying 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:
    /Users/joeljohnson/.npmrc
or on the command line via: npm <command> --key value
Config info can be viewed via: npm help config

npm@5.6.0 /Users/joeljohnson/.nvm/versions/node/v9.4.0/lib/node_modules/npm

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

如何开始解决此错误?

您在文件夹 "Computer Science" 中的项目路径中有一个 space:

/Users/joeljohnson/Documents/Computer Science/Android/GradleFinalProject

这搞乱了 CLI 对 lint 命令行的解析 运行。您有两个选择:

  1. 使用其中没有 space 的路径
  2. 在predeploy lint命令中引用$RESOURCE_DIR变量。

我建议#1,因为在 unix 中文件名中有 spaces 是不常见的,但是如果你想做#2,编辑你的 firebase.json 并寻找这样的行:

  "npm --prefix $RESOURCE_DIR run lint",
  "npm --prefix $RESOURCE_DIR run build"

然后在变量周围加上转义引号:

  "npm --prefix \"$RESOURCE_DIR\" run lint",
  "npm --prefix \"$RESOURCE_DIR\" run build"

这将阻止运行 npm 的 shell 将路径中的 space 解释为命令行参数分隔符。