Search code examples
node.jsfirebasegoogle-cloud-functionsfirebase-cli

Cloud Functions not Deploying from the Command Line


I'm having trouble deploying my cloud functions. I move to the root directory of the android project that holds my functions and use the firebase deploy command, I get this output:

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

How can I begin to troubleshoot this error?


Solution

  • You have a space in the path of your project in the folder "Computer Science":

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

    This is messing up the parsing of the lint command line that the CLI is running. You have two choices:

    1. Use a path that doesn't have a space in it
    2. Quote the $RESOURCE_DIR variable in the predeploy lint command.

    I suggest #1, since it's not conventional in unix to have spaces in filenames, but if you want to do #2, edit your firebase.json and look for lines like this:

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

    Then put escaped quotes around the variable:

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

    This will prevent the shell that runs npm from interpreting the space in your path as a command line argument separator.