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

10

21

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

Tajuanatak answered 21/1, 2018 at 19:14 Comment(1)
Also, after running the deploy command I notice a literal $RESOURCE_DIR folder is created in my project. Putting my package.json file in this folder eliminates this error but seems wrong and just seems to "kick the can" as more errors appear after that.Tajuanatak
M
45

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.

Mullein answered 21/1, 2018 at 19:23 Comment(4)
This totally makes sense and worked, thanks for your very quick response!Tajuanatak
hey @DougStevenson I tried replacing $RESOURCE_DIR with %RESOURCE_DIR% in the npm commands so that it reads : npm --prefix %RESOURCE_DIR% run lint and it still didnt work. Is there another way around this? ThanksRazee
@DejiJames Please ask a new question the describes exactly what does not work.Mullein
@DougStevenson I asked the question here and have edited my question : https://mcmap.net/q/658989/-error-functions-predoploy-error-command-terminated-with-non-zero-exit-code4294963238/7721666Razee
F
2

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

Flotation answered 5/3, 2018 at 13:2 Comment(0)
W
2

Change the following:

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

to

npm --prefix \"%RESOURCE_DIR%\" run lint

in firebase.json file in main structure

{
  "functions": {
    "predeploy": [
      "npm --prefix \"%RESOURCE_DIR%\" run lint"
    ],
    "source": "functions"
  }
}
Woodberry answered 22/10, 2018 at 11:49 Comment(0)
S
2

In windows, while Initializing the firebase Project in CLI using firebase init,In firebase.json file,Change the code to as per below{ "functions": { "predeploy": [ "npm --prefix \"%RESOURCE_DIR%\" run lint" ], "source": "functions" } } After this change, try firebase deploy --only functions command.

Scion answered 22/10, 2018 at 11:53 Comment(0)
M
1

You can fix this by accessing your firebase.json file and delete this line containing RESOURCE_DIR.

Mormon answered 7/7, 2018 at 14:58 Comment(0)
A
1

Apart from the other suggestions, if you change the preflight/predeploy command from:

"npm --prefix \"$RESOURCE_DIR\" run lint", OR
"npm --prefix \"%RESOURCE_DIR%\" run lint"

to

"npm --prefix ./functions run lint"

the issue seems to get fixed. This also resolves it for both Windows and Linux.

To see more details, please see this answer (and further thread): https://github.com/firebase/firebase-tools/issues/610#issuecomment-360147507

Agon answered 2/9, 2018 at 16:18 Comment(0)
S
1

You have to change firebase.json file as shown in here

"npm --prefix functions run lint"
"npm --prefix functions run build"
Sappington answered 13/9, 2018 at 9:40 Comment(1)
Couldn't get RESOURCE_DIR to work, this works consistentlyNobby
I
0

As an extra doing npm --prefix %RESOURCE_DIR% run lint like @Deji James said, made me some progress but still didn't work.

As a suggestion I found this https://github.com/firebase/firebase-tools/issues/610

and @merlinnot says here 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.

worked for me. PS. before deciding to delete, I have done all reinstall things, uninstall things. Only this is worked.

Inexpensive answered 20/2, 2018 at 17:36 Comment(0)
S
0

For ubuntu you need to change firebase.json to following, notice $ before RESOURCE_DIR

{
  "functions": {
    "predeploy": [
      "npm --prefix \"$RESOURCE_DIR\" run lint",
      "npm --prefix \"$RESOURCE_DIR\" run build"
    ]
  }
}

for Windows 10 you need to change firebase.jsonn to following, notice % after and before RESOURCE_DIR

{
  "functions": {
    "predeploy": [
      "npm --prefix \"%RESOURCE_DIR%\" run lint",
      "npm --prefix \"%RESOURCE_DIR%\" run build"
    ]
  }
}
Serg answered 17/10, 2018 at 13:35 Comment(0)
F
0

(for Windows no idea if it work in ios or not)Just delete everything under "Predeploy": it should look like

"predeploy": [ ],

and this work for me hope it will solve your problem also i find this solution here

Fullfaced answered 3/5, 2022 at 16:15 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.