$RESOURCE_DIR predeploy variable
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 What platform are you using?
Could you make sure your functions folder has a package.json file? I'm unable to recreate this error.
@laurenzlong Windows 10, node v8.9.4, firebase-tools v3.17.1. Functions folder does indeed have a package.json file.
Does the command work for you if you replace $RESOURCE_DIR with %RESOURCE_DIR%?
@tinaliang It does work!
I'm seeing this on Windows as well, but we use both Windows and Linux, so is there away to handle both platforms?
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
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.
Same Error here: Running command: npm --prefix %RESOURCE_DIR% run lint
Usage: npm
where
npm
Also getting this error!
also getting this error on Mac. This is so buggy!!!!!!
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 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.
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!
@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 Does NPM have it's own, cross-platform env var stucture that could be leveraged?
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 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.
Can I kindly ask some Windows dev which one do you guys use in development?
@merlinnot I typically use PowerShell
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: