0

我在部署云功能时遇到问题。我移动到包含我的函数的 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

错误:函数预部署错误:命令以非零退出代码终止1

如何开始解决此错误?

4

1 回答 1

3

您在“计算机科学”文件夹中的项目路径中有一个空格:

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

这弄乱了 CLI 正在运行的 lint 命令行的解析。你有两个选择:

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

我建议 #1,因为在 unix 中,文件名中有空格不是常规的,但如果你想做 #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 将路径中的空格解释为命令行参数分隔符。

于 2018-02-27T06:20:34.120 回答