Firebase-tools: Deploy error on Windows: "Running command: npm --prefix "$RESOURCE_DIR" run lint"

Created on 9 Jul 2018  路  20Comments  路  Source: firebase/firebase-tools

=== Deploying to 'help-baba'...

i deploying functions, hosting
Running command: npm --prefix "$RESOURCE_DIR" run lint
npm ERR! Windows_NT 10.0.17134
npm ERR! argv "D:\installationFolder\nodejs\node.exe" "D:\installationFolder\nodejs\node_modules\npm\bin\npm-cli.js" "--prefix" "%RESOURCE_DIR%" "run" "lint"
npm ERR! node v6.11.5
npm ERR! npm v3.10.10
npm ERR! path G:\HelpBaba\%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 'G:\HelpBaba\%RESOURCE_DIR%\package.json'
npm ERR! enoent ENOENT: no such file or directory, open 'G:\HelpBaba\%RESOURCE_DIR%\package.json'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! Please include the following file with any support request:
npm ERR! G:\HelpBaba\npm-debug.log

Error: functions predeploy error: Command terminated with non-zero exit code4294963238

I am trying to deploy on firebase but its giving this error. Please Help!

Most helpful comment

I think I figured out what's going on. Windows PowerShell has a different syntax for environment variables than Windows Cmd.exe/Command Prompt. It uses the syntax $Env:FOO instead of %FOO%(see article) During deployment, Firebase CLI was dynamically substituting \"$RESOURCE_DIR\" for %RESOURCE_DIR% when it detects that the system is Windows, that is not working for PowerShell (and may not working for some other command line tools on Windows as well)

In the April update to Windows 10, Microsoft made PowerShell the default command line app, which is probably why there's so many users that have run into this issue lately.

If you are a Windows user, and you are running into this bug, you have a couple of options.
1) Completely remove the "predeploy" field from firebase.json if you don't actually need linting or building prior to deployment
2) Edit the predeploy script to use the right syntax for your command line tool:

// firebase.json

// before: (it may not look exactly the same depending on which CLI you were 
// using when you ran "firebase init"
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint"
]

// after: (for PowerShell)
"predeploy": [
"npm --prefix $Env:RESOURCE_DIR run lint"
]

// after: (for Cmd.exe)
"predeploy": [
"npm --prefix %RESOURCE_DIR% run lint"
]

This should hopefully unblock affected users while we try to fix this. If anyone has suggestions on how to make a script work across platforms and across command line tools, please share!

All 20 comments

What's your firebase-tools version?

Run "firebase --version"

And what does your "firebase.json" look like?

And what is your platform? (Windows vs OS X)

I am on windows 10
firebase version 3.19.3

This is how my firebase.json looks like

{
"hosting": {
"public": "public",
"rewrites": [
{
"source": "",
"function": "app"
}
],
"ignore": [
"firebase.json",
"
/.*",
"/node_modules/"
]
},
"functions": {
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint"
],
"source": "functions"
},
"database": {
"rules": "database.rules.json"
}
}
@laurenzlong

@laurenzlong I was able to deploy my static pages successfully but when i am trying to deploy firebase functions I am getting errors.. and now I am getting the following errors:

G:\HelpBaba>firebase deploy

=== Deploying to 'help-baba'...

i deploying database, functions, hosting
Running command: npm --prefix "$RESOURCE_DIR" run lint

functions@ lint G:\HelpBaba\%RESOURCE_DIR%
eslint .

Oops! Something went wrong! :(

ESLint: 5.1.0.
No files matching the pattern "." were found.
Please check for typing mistakes in the pattern.

npm ERR! Windows_NT 10.0.17134
npm ERR! argv "D:\installationFolder\nodejs\node.exe" "D:\installationFolder\nodejs\node_modules\npm\bin\npm-cli.js" "--prefix" "%RESOURCE_DIR%" "run" "lint"
npm ERR! node v6.11.5
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! functions@ lint: eslint .
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the functions@ lint script 'eslint .'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the functions package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! eslint .
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs functions
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls functions
npm ERR! There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! Please include the following file with any support request:
npm ERR! G:\HelpBaba\npm-debug.log

Error: functions predeploy error: Command terminated with non-zero exit code1

Having trouble? Try firebase deploy --help

when i do "firebase serve --only hosting,functions" everything works fine locally. Error occurs when deploying.

Thanks for posting, looks like the pre-deploy linting script that was set up by "firebase init" is not behaving well. I'll have to debug further as to why that's happening on windows (I thought we had fixed it). In the meanwhile, you can just delete the following from firebase.json:

"predeploy": [
"npm --prefix "$RESOURCE_DIR" run lint"
]

I think I figured out what's going on. Windows PowerShell has a different syntax for environment variables than Windows Cmd.exe/Command Prompt. It uses the syntax $Env:FOO instead of %FOO%(see article) During deployment, Firebase CLI was dynamically substituting \"$RESOURCE_DIR\" for %RESOURCE_DIR% when it detects that the system is Windows, that is not working for PowerShell (and may not working for some other command line tools on Windows as well)

In the April update to Windows 10, Microsoft made PowerShell the default command line app, which is probably why there's so many users that have run into this issue lately.

If you are a Windows user, and you are running into this bug, you have a couple of options.
1) Completely remove the "predeploy" field from firebase.json if you don't actually need linting or building prior to deployment
2) Edit the predeploy script to use the right syntax for your command line tool:

// firebase.json

// before: (it may not look exactly the same depending on which CLI you were 
// using when you ran "firebase init"
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint"
]

// after: (for PowerShell)
"predeploy": [
"npm --prefix $Env:RESOURCE_DIR run lint"
]

// after: (for Cmd.exe)
"predeploy": [
"npm --prefix %RESOURCE_DIR% run lint"
]

This should hopefully unblock affected users while we try to fix this. If anyone has suggestions on how to make a script work across platforms and across command line tools, please share!

Thank you very much for the help. It worked! really appreciate your help!

You're welcome! I'm going to reopen the issue so people can see the workaround.

I'm also modifying the behavior of "firebase init" so it doesn't create the predeploy script by default (https://github.com/firebase/firebase-tools/pull/836), to lower the number of people that will run into this.

Not sure if I understood your previous comment fully, but as #836 already merged I assumed you this is fixed, however Functions still has this enabled by default:
I'm on win10 1803, powerShell

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

@hgghyxo Was the project initialized before or after you upgraded firebase-tools?

after :) but to make sure, just run an new test, empty dir, new firebase init same result

Oh I see, you are using TypeScript. For TypeScript, we still default to true for linting, because a pre-deploy hook is already required for building the source code prior to deployment. If this is causing you issues, you can replace \"$RESOURCE_DIR\" with the name of your functions directory (but then you would have to always run firebase deploy from the main project directory), or you can use a format for environment variables that's compatible with PowerShell (I think that would be $Env:RESOURCE_DIR but haven't tested it to know.)

Thanks for the workaround,

But It's such a bad experience getting started
Shouldn't this be long fixed by now?...

@laurenzlong

Just to note that I'm using Powershell, Firebase-Tools 4.2.0, Node Js 8.11.4

I tried the one below and it doesn't work. :(

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

This works: :)

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

I am seeing this issue on Window 8.1 pro with latest 6.0.0 firebase-tools.
This bug has been opened for months. If you don't know how to fix the bug, you should at least update the section "Initialize Firebase SDK for Cloud Functions" (Ref: https://firebase.google.com/docs/functions/get-started) to warn users they have to update the redeploy scripts on windows.

Also, when I googled this issue, I first found an earlier bug (https://github.com/firebase/firebase-tools/issues/610) opened Jan 18th which was closed as a duplicate of this bug opened July 9th. That initially cause some additional confusion because I thought the issue was fixed. The original bug should have been left open.

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

This works for me..
Thank you.

Closing since we don't have a permanent fix on the immediate horizon. Please see discussions and links for workarounds.

If none of the workarounds work, please open a new issue with your exact problem.

Run npm install from within your functions directory to make sure you have the correct node modules installed for your functions.

Was this page helpful?
0 / 5 - 0 ratings