Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cloud Functions deploy error during lint on Windows: "enoent ENOENT: no such file or directory"

Following the firebase function getting started guide and getting a seemingly simple error once trying to deploy with:

firebase deploy --only functions

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

The package.json file does exist just as the tutorial shows in my project/functions/package.json. Have tried changing or printing out the RESOURCE_DIR env with no success. Assuming it would be scoped inside of the NPM shell environment.

npm version: 5.6.0

node version: 8.9.0

like image 838
Robert Brand Avatar asked Jan 21 '18 19:01

Robert Brand


2 Answers

This is a known problem with the Firebase CLI 3.17.0 through at least 3.17.3, but only on Windows. You can fix this on your machine by editing firebase.json at the root of your project and replacing $RESOURCE_DIR with %RESOURCE_DIR% in the npm commands you see there. The former is the unix syntax way to use an environment variable, whereas the latter is the Windows command shell syntax. Since you're using Windows, you need to use the Windows syntax.

The team is looking into ways to prevent having to make changes to the config files you use, as it's not really convenient for teams that works across platform to keep changing the same file back and forth.

EDIT: This issue should be fixed with projects created with CLI version 3.17.5.

like image 125
Doug Stevenson Avatar answered Oct 19 '22 07:10

Doug Stevenson


When running

firebase init functions

I use this configuration

? What language would you like to use to write Cloud Functions? JavaScript
//TypeScript doesn't work
? Do you want to use ESLint to catch probable bugs and enforce style? Yes
//If you don't you will get a missing file lint
? File functions/package.json already exists. Overwrite? Yes
? Do you want to install dependencies with npm now? Yes
//Why not

Then if use windows

Replace $RESOURCE_DIR by %RESOURCE_DIR% in firebase.json

like image 2
Kangudie Muanza - Killmonger Avatar answered Oct 19 '22 09:10

Kangudie Muanza - Killmonger