firebase-tools icon indicating copy to clipboard operation
firebase-tools copied to clipboard

$RESOURCE_DIR predeploy variable

Open dylanjmcdonald opened this issue 8 years ago • 86 comments

Version info

3.17.1

Steps to reproduce

Set up cloud functions via firebase init and selected TypeScript Run firebase deploy --only functions

Expected behavior

Expecting firebase-tools to deploy the cloud functions.

Actual behavior

Receive the following error message:

deploying functions Running command: npm --prefix $RESOURCE_DIR run lint npm ERR! path C:\PATH_REMOVED_FOR_SHARING_PURPOSES\$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:\PATH_REMOVED_FOR_SHARING_PURPOSES\$RESOURCE_DIR\package.json' npm ERR! enoent This is related to npm not being able to find a file.

Is this something that needs to be set up manually or should firebase-tools take care of this? I am not seeing any documentation for this.

dylanjmcdonald avatar Jan 19 '18 05:01 dylanjmcdonald

@dylanjmcdonald What platform are you using?

laurenzlong avatar Jan 19 '18 19:01 laurenzlong

Could you make sure your functions folder has a package.json file? I'm unable to recreate this error.

tinaliang avatar Jan 19 '18 19:01 tinaliang

@laurenzlong Windows 10, node v8.9.4, firebase-tools v3.17.1. Functions folder does indeed have a package.json file.

dylanjmcdonald avatar Jan 19 '18 19:01 dylanjmcdonald

Does the command work for you if you replace $RESOURCE_DIR with %RESOURCE_DIR%?

tinaliang avatar Jan 19 '18 19:01 tinaliang

@tinaliang It does work!

dylanjmcdonald avatar Jan 19 '18 20:01 dylanjmcdonald

I'm seeing this on Windows as well, but we use both Windows and Linux, so is there away to handle both platforms?

ScottMorris avatar Jan 22 '18 19:01 ScottMorris

Same here. I followed this tutorial and activated lint. When I execute (on a Mac)

npm --prefix $RESOURCE_DIR run lint

I get this error:

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

[email protected] /usr/local/lib/node_modules/npm

Did you mean one of these?
    list
    link
    ping

nico75005 avatar Jan 24 '18 08:01 nico75005

What I ended up doing was editing the firebase.json file and changed the preflight commands to be npm --prefix ./functions run lint. This seems to work on both Linux and Windows. The environment variable is only compatible with shells that use that structure.

ScottMorris avatar Jan 24 '18 14:01 ScottMorris

Same Error here: Running command: npm --prefix %RESOURCE_DIR% run lint

Usage: npm

where 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 -h quick help on npm -l display full usage info npm help search for help on npm help npm involved overview

cmwakio avatar Jan 24 '18 14:01 cmwakio

Also getting this error!

finppp avatar Jan 26 '18 13:01 finppp

also getting this error on Mac. This is so buggy!!!!!!

ricardosobral avatar Jan 28 '18 17:01 ricardosobral

Hey guys, you all probably have sth in your predeploy in firebase.json, don't you? Just delete what you have there for now if it's not that important. We're actively working on this issue.

@ricardosobral It's a Windows-specific "bug" (personally, I don't think it's a bug, but it is being discussed elsewhere). Please make a new issue if you're experiencing some problems on Mac, it has to be sth else.

merlinnot avatar Jan 28 '18 17:01 merlinnot

@merlinnot it seems the issue is the predeployment scripts are using an environment variable that isn't compatible with all shells. The use of the script is a clever work around for compiling TypeScript before it is deployed, so removing it would render that method of precompiling useless.

The change I made was to replace the env var with the relative path to my functions folder and that worked perfectly on both platforms. It is probably not the perfect fix, as it hard codes in the path, but it keeps the desired functionality alive.

ScottMorris avatar Jan 28 '18 18:01 ScottMorris

I deleted everything and re-installed. Seems to work now. Took me ages to find all the files. A removal feature would be great. Tks for your prompt reply. Better than bug free is good support ;) Well done!

ricardosobral avatar Jan 28 '18 18:01 ricardosobral

@ScottMorris Exactly, the problem is with env variables. I know it must work eventually, I was just trying to give you some advice for the time being ;)

merlinnot avatar Jan 28 '18 19:01 merlinnot

@merlinnot Does NPM have it's own, cross-platform env var stucture that could be leveraged?

ScottMorris avatar Jan 28 '18 20:01 ScottMorris

I have literally no experience with Windows, I'm using Unix-based OSs since forever. As I understand, Windows has three CLIs available: CMD, PowerShell and Bash. Can I kindly ask some Windows dev which one do you guys use in development?

merlinnot avatar Jan 28 '18 22:01 merlinnot

@merlinnot Have the same error in windows. I am using cmd to deploy functions. Error is resolved when I deleted all the files except Function and firebase.Json leaving out just the curly braces. It works fine on Ubuntu and it doesn't have any error.

ManminderTomar1223 avatar Jan 29 '18 11:01 ManminderTomar1223

Can I kindly ask some Windows dev which one do you guys use in development?

@merlinnot I typically use PowerShell

dylanjmcdonald avatar Jan 29 '18 16:01 dylanjmcdonald

This will hopefully be fixed by #644

Can anyone try npm install -g git://github.com/firebase/firebase-tools#master and let us know if deploying works without messing with firebase.json in Windows now? It did in our own tests but I'd love community confirmation. :smile:

mbleigh avatar Jan 29 '18 22:01 mbleigh