Open Kar1Huang opened 6 years ago
I have a very similar issue, get error message:
Node.js v6.11.x or greater is required to run the Emulator! ⚠ functions: Failed to load functions source code. Ensure that you have the latest SDK by running npm i --save firebase-functions inside the functions directory. ⚠ functions: Error from emulator. Error: Emulator crashed! Check the log file...
Running node 6.11.1 via nvm. The log file does not add anything. I have also run the command suggested above and tried all suggestions on the page: https://github.com/GoogleCloudPlatform/cloud-functions-emulator/wiki/Troubleshooting
"dependencies": { "azure": "^2.2.1-preview", "firebase-admin": "~5.4.0", "firebase-functions": "^0.7.4", "request": "^2.83.0", "request-promise": "^4.2.2", "secure-compare": "^3.0.1", "web3": "^1.0.0-beta.24" },
I am able to deploy the functions fine and they work? This is really frustrating, Thanks.
same issue here:
Win7 Ent x64
firebase-tools@3.16.0
"firebase-admin": "^5.5.0",
"firebase-functions": "^0.7.5"
No errors in the firebase-debug.log
file except:
[warn] ! functions: Failed to emulate hello
same issue with:
"firebase-admin": "^5.6.0",
"firebase-functions": "latest"
console messages:
i functions: Preparing to emulate functions. i hosting: Serving hosting files from: public
- hosting: Local server: http://localhost:5000
! functions: Failed to emulate hello
Similar issue in a fresh project
macOS@10.13.2 firebase-tools@3.17.1 firebase-admin@5.8.1 firebase-functions@0.8.1 node@6.11.3
output:
Node.js v6.11.x or greater is required to run the Emulator!
functions: Error from emulator. Error: Emulator crashed! Check the log file...
Guys, I seemed to fix my issue, I am not quite sure which command fixed it but below are some that I ran.
Like I said I I don't know which of the above was the fix and the order is not correct but just putting here as it may help someone else. I think that getting the terminal using 6.11.5 is the key.
Using nvm
. The move from 6.11.1 to 6.11.5 resolved this for me.
In my case moving to v6.12.3 fixed the problem, I think the main problem is that the official documentation isn't up to date and is pointing to a wrong version
I tried using nvm
for 6.11.5
and cloud functions still fail to emulate locally :(
Okay so what finally worked for me is going into this dir: ~/.config/configstore/ and then deleting everything to do with @google-cloud and firestore*.json. Then I went back into the console and did a firebase login, I think what's happening is the token is expiring and it's not refreshing it our your user it getting dropped, something in that universe. Very annoying.
Okay so just another note, I am able to repeat the cause and fix here. So in my case I am trying to debug the functions in VS Code, so I followed this guide:
When I run functions start
and then functions deploy api
in my case I get an error:
ERROR: Function load error: Code could not be loaded.
ERROR: Does the file exists? Is there a syntax error in your code?
ERROR: Detailed stack trace: module.js:471
throw err;
^
And then if I then try to run:
firebase serve --only functions
I get:
i functions: Preparing to emulate functions.
⚠ functions: Failed to emulate api
And at this point I go into ~/.config/configstore/ and delete the @google-cloud folder and firestore json file, then drop back into the console and run:
firebase login
(go through the login process) and then finally firebase use project-name
and then firebase serve --only functions
works fine again.
Hope this helps someone and I hope this gets fixed, I would really like to use VSCode to debug this stuff. Thanks!
June-04-2018 UPDATE:
I ran into this issue again when trying to run an API that was enabled, in this case it was the natural language API, I got the error:
Error: 7 PERMISSION_DENIED: Cloud Natural Language API has not been used in project XXXXXX before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/language.googleapis.com/overview?project=XXXXXXXX then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.
Of course that project ID doesn't go any where and of course the API was enabled, turns out this fix also works for this error, just wanted to add it since apparently you get here at least 2 different ways.
Thanks @shaunc869 -- fixed my issue.
I deleted ~/.config/configstore/@google-cloud
and that fixed it for me. I didn't have to login
or use
.
What is Windows 10 equivalent folder path to ~/.config/configstore/@google-cloud
?
@paritosh149 c:\users\<your username.config\configstore\@google-cloud
Anyway, in my case deleting this folder did not resolve the problem
I just discovered the --debug
options, than I run firebase deploy --only functiotions -debug
and I got this
[2018-06-16T09:06:49.437Z] Parsing function triggers
[2018-06-16T09:06:50.197Z] Error while deploying to emulator: RangeError [ERR_OUT_OF_RANGE]: The value of "value" is out of range. It must be >= -2147483648 and <= 2147483647. Received 2858637923
RangeError [ERR_OUT_OF_RANGE]: The value of "value" is out of range. It must be >= -2147483648 and <= 2147483647. Received 2858637923
at checkInt (internal/buffer.js:35:11)
at writeU_Int32LE (internal/buffer.js:515:3)
at Buffer.writeInt32LE (internal/buffer.js:684:10)
at Object.entryHeaderToBinary (C:\Users\mirko\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\adm-zip\headers\entryHeader.js:216:18)
at Object.packHeader (C:\Users\mirko\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\adm-zip\zipEntry.js:260:39)
at C:\Users\mirko\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\adm-zip\zipFile.js:198:41
at Array.forEach (<anonymous>)
at Object.compressToBuffer (C:\Users\mirko\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\adm-zip\zipFile.js:182:23)
at Object.writeZip (C:\Users\mirko\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\adm-zip\adm-zip.js:454:
```32)
at client.generateUploadUrl.then.then (C:\Users\mirko\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\@google-cloud\functions-emulator\src\cli\controller.js:168:13)
! functions: Failed to emulate refresh
I tried to update cli tools,
npm install -g firebase-tools
C:\Users\mirko\AppData\Roaming\npm\firebase -> C:\Users\mirko\AppData\Roaming\npm\node_modules\firebase-tools\bin\firebase
+ firebase-tools@3.18.6
added 1 package, removed 1 package and updated 5 packages in 81.135s
Then the situation is more wrong than before
$ firebase deploy --only functions
internal/modules/cjs/loader.js:596
throw err;
^
Error: Cannot find module 'update-notifier'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:594:15)
at Function.Module._load (internal/modules/cjs/loader.js:520:25)
at Module.require (internal/modules/cjs/loader.js:650:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (C:\Users\mirko\AppData\Roaming\npm\node_modules\firebase-tools\bin\firebase:5:22)
at Module._compile (internal/modules/cjs/loader.js:702:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
at Module.load (internal/modules/cjs/loader.js:612:32)
at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
at Function.Module._load (internal/modules/cjs/loader.js:543:3)
Why firebase cli make us much trouble always? I'm tired of errors, switching to azure
Try AWS too.
@realtebo have you tried the patch here? https://github.com/firebase/firebase-tools/issues/770#issuecomment-390622784
that fixed this node 10 error for me:
RangeError [ERR_OUT_OF_RANGE]: The value of "value" is out of range. It must be >= -2147483648 and <= 2147483647. Received 2413610064
at checkInt (internal/buffer.js:35:11)
at writeU_Int32LE (internal/buffer.js:515:3)
at Buffer.writeInt32LE (internal/buffer.js:684:10)
at Object.entryHeaderToBinary (/Users/alex/.config/yarn/global/node_modules/adm-zip/headers/entryHeader.js:216:18)
@alexlouden : I'll try. If works, I'll try to open a PR into the related repo
I had the same problem for a different reason than the one mentionned above.
In my case, I had a console running firebase serve
, and trying to run firebase functions:shell
in another one failed.
Killing the process of firebase serve
and running firebase functions:shell
solved the problem. It looks like both can't run at the same time.
I did try the workaround in https://github.com/GoogleCloudPlatform/cloud-functions-emulator/issues/173#issuecomment-369001442 before, so it may or may not have changed something.
@jberube : sorry, I don't understand.
"I did try the workaround in #173 (comment) before, so it may or may not have changed something."
You have already tried this workaround. But have you still the problem or is it fixed? "May or may not" ... is confusing me ...
@google-admin : please, trash this dependency ! it's still using
"engines": {
"node": ">=0.3.0"
}
@realtebo I've updated my comment to be clearer.
Problem is solved for me. I'm not sure if deleting the ~/.config/configstore/@google-cloud
folder was necessary in my case.
Had same error. It appears that it was happening for me because I had another functions process running. After closing it I could run the other functions process fine
I still have this issue locally, deploying to firebase cloud works fine(remote). Re-installed node 6.11.5, restarted function process had no effect. deleting google-cloud had no effect. (c:\users<your username.config\configstore@google-cloud)
i functions: Preparing to emulate functions.
ERROR: Function load error: Code could not be loaded.
ERROR: Does the file exists? Is there a syntax error in your code?
ERROR: Detailed stack trace: module.js:471
throw err;
^
What is causing this issue? Any suggestions, advises ? Thanks.
I think after a day struggle it magically started working. I am not sure what really helped, I believe it is mostly related to reinstalling firebase functions and node versions.
I still have some minor issues like port locked.
error: restPort (5002) is already in use
error: SUPERVISOR error Error: listen EADDRINUSE 127.0.0.1:5001
at Object.exports._errnoException (util.js:1020:11)
at exports._exceptionWithHostPort (util.js:1043:20)
at Server._listen2 (net.js:1262:14)
at listen (net.js:1298:10)
at net.js:1408:9
at GetAddrInfoReqWrap.asyncCallback [as callback] (dns.js:62:16)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:81:10)
error: supervisorPort (5001) is already in use
@prakis look for other processes using the same ports (5001, 5002). I had this error in another context in the past because my console emulator would close but the node process was still running.
Thats right @jberube, the previous node process is still running in the background and locking those ports. Thank you.
Node 6.11.5 is the only version which is working for me. Strangely other firebase project works fine with latest node version.
$ nvm use 6.11.5 Now using node v6.11.5 (npm v3.10.10) $ nvm alias defalt 6.11.5 defalt -> 6.11.5 (-> v6.11.5) $ node --version v6.11.5 $ npm run shell
functions@ shell /opt/dev/angular-firebase-projects/cloud-functions/cloud-functions-master-course/functions npm run build && firebase experimental:functions:shell
functions@ build /opt/dev/angular-firebase-projects/cloud-functions/cloud-functions-master-course/functions tsc
i functions: Preparing to emulate functions. ✔ functions: createUserRecord info: Worker for createUserRecord closed due to file changes. ✔ functions: basicHttp info: Worker for basicHttp closed due to file changes. ✔ functions: api firebase >
I have added sudo before command and then works fine
For anyone encountering this issue (including future me):
Waiting for operation to finish...done.
Deploying function.........failed.
ERROR: Function worker crashed with exit code: 1
undefinedWarning, estimating Firebase Config based on GCLOUD_PROJECT. Initializing firebase-admin may failfs.js:1384
throw error;
^
functions stop
firebase login
firebase use PROJECT_ID
firebase serve --only functions
Now functions should work, as somehow this refreshes the authentication... I think
functions config set projectId PROJECT_ID
functions deploy
when this inevitably happens again, I'll update this comment.
use sudo before serve !
I deleted the files inside of ~/.config/configstore/@google-cloud/functions-emulator
(careful finding that directory because of the @
symbol) and then ran it again and everything worked fine
macOS@10.12.4 firebase-tools@3.16.0 firebase-admin@5.4.3 firebase-functions@0.7.3 node@8.*
run
firebase serve --only functions
output:
while if i switch to node@6.*
when i go to
/usr/local/lib/node_modules/firebase-tools/node_modules/grpc/src/node/extension_binary
i only gotnode-v57-darwin-x64-unknown
instead ofnode-v48-darwin-x64-unknown