Cloud Functions of Firebase failed to emulate - node.js

When I try to run npm run serve:
"build": "./node_modules/.bin/tsc",
"serve": "npm run build && firebase serve --only functions",
I get an output that says it failed to emulate my functions:
> npm run build && firebase serve --only functions
> functions# build /Users/eliyacohen/apps/app-name/functions
> tsc
=== Serving from '/Users/eliyacohen/apps/app-name'...
i functions: Preparing to emulate functions.
⚠ functions: Failed to emulate payment-create
⚠ functions: Failed to emulate payment-process
When I open firebase-debug.log for further information, I see:
...
Sat Mar 31 2018 18:48:05 GMT+0300 (IDT)
[debug] [2018-03-31T15:48:06.665Z] <<< HTTP RESPONSE 200
[debug] [2018-03-31T15:48:06.666Z] Starting #google-cloud/functions-emulator
[debug] [2018-03-31T15:48:08.254Z] Parsing function triggers
[debug] [2018-03-31T15:48:10.194Z] Error while deploy to emulator: Error: connect ECONNREFUSED 127.0.0.1:5001
at Object.exports._errnoException (util.js:1020:11)
at exports._exceptionWithHostPort (util.js:1043:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1090:14)
[debug] [2018-03-31T15:48:10.195Z] Error while deploy to emulator: Error: connect ECONNREFUSED 127.0.0.1:5001
at Object.exports._errnoException (util.js:1020:11)
at exports._exceptionWithHostPort (util.js:1043:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1090:14)
[warn] ⚠ functions: Failed to emulate payment-create
[warn] ⚠ functions: Failed to emulate payment-process
As far as I can understand, it couldn't reach 127.0.0.1:5001 so it could serve these functions locally?
I know that there's nothing wrong with my code, since firebase deploy --only functions deploys my functions with no errors.
I tried to remove entirely Node.js and reinstall it, downgrade and upgrade it. Same goes for the global modules.
My main folder (../functions) is built on Ionic Framework. Does it have something to do with this?
Environment:
Running on MacOS High Sierra
Node.js v6.11.5
NPM version 3.10.10
firebase-tools: 3.17.7 (Global)
firebase-admin: ^5.11.0,
firebase-functions: ^0.9.1

Since I see that lots of people are still encountering with the following error, try to update your node version the latest stable version (or >= 10)

try with different port. example
firebase serve --port 3000 --only functions

Related

Firebase Bcrypt Issue

I'm trying to run my web app locally using the firebase emulator suite. However, I keep getting an issue that seems to be caused by bcrypt and Apple M1. Here are some of the things I've tried to resolve the error:
Reinstall bcrypt (npm uninstall and npm i bcrypt)
Copied over the entire dir and tried running the web app locally using a Macbook with an Intel i7 CPU
What doesn't make sense to me is I have no trouble running this web app locally when just using npm start though.
Console Err Msg:
(conda-env) btang#BLT-WorkBook-Pro functions % node --version
v16.14.2
(conda-env) btang#BLT-WorkBook-Pro functions % firebase emulators:start
i emulators: Starting emulators: functions, hosting
⚠ functions: The following emulators are not running, calls to these services from the Functions emulator will affect production: auth, firestore, database, pubsub, storage
⚠ Your requested "node" version "16" doesn't match your global version "12". Using node#12 from host.
i hosting: Serving hosting files from: build
✔ hosting: Local server: http://localhost:5000
i ui: Emulator UI logging to ui-debug.log
i functions: Watching "/Users/btang/Developer/Projects/react-webapp/functions" for Cloud Functions...
i emulators: Shutting down emulators.
i ui: Stopping Emulator UI
⚠ Emulator UI has exited upon receiving signal: SIGINT
i functions: Stopping Functions Emulator
i hosting: Stopping Hosting Emulator
i hub: Stopping emulator hub
i logging: Stopping Logging Emulator
Error: Error occurred while parsing your function triggers.
Error: dlopen(/Users/btang/Developer/Projects/react-webapp/functions/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node, 0x0001): tried: '/Users/btang/Developer/Projects/react-webapp/functions/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64'))
at tryImporting (pkg/prelude/bootstrap.js:1736:37)
at process.dlopen (pkg/prelude/bootstrap.js:1762:5)
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1186:18)
at Module.load (internal/modules/cjs/loader.js:984:32)
at Function.Module._load (internal/modules/cjs/loader.js:877:14)
at Module.require (internal/modules/cjs/loader.js:1024:19)
at Module.require (pkg/prelude/bootstrap.js:1338:31)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/Users/btang/Developer/Projects/react-webapp/functions/node_modules/bcrypt/bcrypt.js:6:16)
at Module._compile (internal/modules/cjs/loader.js:1136:30)
Any ideas?
Thanks in advance!

webpack --progress Error: write EINVAL

I'm on Windows 10 recently upgraded my node.js to version 7.1.0. I started to get the following error every time I ran the webpack command with --progress flag.
$ webpack --progress
Node Environment: development events.js:160
throw er; // Unhandled 'error' event
^
Error: write EINVAL
at exports._errnoException (util.js:1022:11)
at WriteStream.Socket._writeGeneric (net.js:715:26)
at WriteStream.Socket._write (net.js:734:8)
at doWrite (_stream_writable.js:334:12)
at writeOrBuffer (_stream_writable.js:320:5)
at WriteStream.Writable.write (_stream_writable.js:247:11)
at WriteStream.Socket.write (net.js:661:40)
at E:\Projects\wad\node_modules\webpack\bin\convert-argv.js:421:20
at Compiler.<anonymous> (E:\Projects\wad\node_modules\webpack\lib\ProgressPlugin.js:77:4)
at Compiler.applyPlugins (E:\Projects\wad\node_modules\tapable\lib\Tapable.js:26:37)
at Compiler.<anonymous> (E:\Projects\wad\node_modules\webpack\lib\Compiler.js:193:12)
at Compiler.emitRecords (E:\Projects\wad\node_modules\webpack\lib\Compiler.js:282:37)
at Compiler.<anonymous> (E:\Projects\wad\node_modules\webpack\lib\Compiler.js:187:11)
at E:\Projects\wad\node_modules\webpack\lib\Compiler.js:275:11
at Compiler.applyPluginsAsync (E:\Projects\wad\node_modules\tapable\lib\Tapable.js:60:69)
at Compiler.afterEmit (E:\Projects\wad\node_modules\webpack\lib\Compiler.js:272:8)
at Compiler.<anonymous> (E:\Projects\wad\node_modules\webpack\lib\Compiler.js:267:14)
at E:\Projects\wad\node_modules\async\lib\async.js:52:16
at done (E:\Projects\wad\node_modules\async\lib\async.js:246:17)
at E:\Projects\wad\node_modules\async\lib\async.js:44:16
at E:\Projects\wad\node_modules\graceful-fs\graceful-fs.js:43:10
at FSReqWrap.oncomplete (fs.js:111:15)
It works fine without the --progress flag and webpack --progress was working fine on node.js v6.x.x. Using webpack --progress with node v.7.1.0 on the same project but another windows 10 machine also works fine.
What does this error mean?
This is a problem of the version node, use the version 6.9 and success
I had the same problem, and i uninstall node7.1, reboot and install node6.9 and all ok
It seems there a bug at node js v7.1.0 nodejs/node#9542. Update to the latest version v7.3.0 and everything will be ok.

"ionic start project test" giving error ENOTFOUND github:443

I am trying to create an ionic application but getting below error
Command:-
ionic create testapp sidemenu
Error: getaddrinfo ENOTFOUND github.com github.com:443
"
Creating Ionic app in folder ~..\conference base
d on sidemenu project
Downloading: https://github.com/driftyco/ionic-app-base/archive/master.zip
Error Initializing app: Error: getaddrinfo ENOTFOUND github.com github.com:443
Error: getaddrinfo ENOTFOUND github.com github.com:443
at errnoException (dns.js:26:10)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:77:26)
getaddrinfo ENOTFOUND github.com github.com:443 (CLI v1.7.8)
Your system information:
Cordova CLI: 5.4.0
Ionic CLI Version: 1.7.8
Ionic App Lib Version: 0.6.4
OS: Windows 7 SP1
Node Version: v4.2.1
"
Please suggest how to resolve this, I am new in phonegap/ionic/nodejs
[EDIT] proxy has already been configured successfully.
You have to update your ionic version. This command can't be launch with a CLI version under v1.7.10.
Have a look at the tutorial : https://creator.ionic.io/app/dashboard/help/videos
I am also getting that same Issue.
I also set proxy, http-proxy for npm already but still getting issue
I Fixed this by setting proxy in ionic module as explained in this link
Basically you just need to add below line at line no 421 (approx. just before tunnel creation in code) in require.js for setting proxy and then this Ionic CLI will start working.
// hack to add proxy
self.proxy = 'http://proxy-ip:proxy-port';

Can't start bundled Meteor app: "Error: failed to connect to [127.0.0.1:3001]"

I'm trying to bundle and run Meteor (v1.0) as a raw Node project.
Here are the steps I've taken:
$ cd app_dir
$ meteor build build_dir.
$ cd build_dir/programs/server
$ npm install
$ cd build_dir
$ PORT=3000 MONGO_URL=mongodb://127.0.0.1:3001/meteor node main.js
At this point I get an error:
Exception in callback of async function: Error: failed to connect to [127.0.0.1:3001]
at null.<anonymous> (/Users/byrnef87/Sites/lookback-site/bundle/programs/server/npm/mongo/node_modules/mongodb/lib/mongodb/connection/server.js:536:74)
at emit (events.js:106:17)
at null.<anonymous> (/Users/byrnef87/Sites/lookback-site/bundle/programs/server/npm/mongo/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:150:15)
at emit (events.js:98:17)
at Socket.<anonymous> (/Users/byrnef87/Sites/lookback-site/bundle/programs/server/npm/mongo/node_modules/mongodb/lib/mongodb/connection/connection.js:516:10)
at Socket.emit (events.js:95:17)
at net.js:440:14
at process._tickCallback (node.js:419:13)
Any ideas on what could be causing this or how to debug it?
Thanks!
The solution that ended up fixing it for me was just re-cloning the repo, upgrading node to the latest version, upgrading MongoDB to the latest version and running it with a ROOT_URL like so:
ROOT_URL=http://localhost:3000 PORT=3000 MONGO_URL=mongodb://127.0.0.1:27017/meteor node main.js
Once you've started mongodb you need to provide the port it is running on in the MONGO_URL:
PORT=3000 MONGO_URL=mongodb://127.0.0.1:27017/meteor node main.js

error when starting the server with grunt or node server

I am trying to use the mean stack as described here : http://mean.io/
after install, when making "grunt", there is an error :
debugger listening on port 5858
4 Jan 01:47:40 - [nodemon] reading ignore list
Express app started on port 3000
events.js:72
throw er; // Unhandled 'error' event
^
Error: failed to connect to [localhost:27017]
at null.<anonymous> (/mean/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:540:74)
at EventEmitter.emit (events.js:106:17)
at null.<anonymous> (/mean/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:140:15)
at EventEmitter.emit (events.js:98:17)
at Socket.<anonymous> (/mean/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection.js:478:10)
at Socket.EventEmitter.emit (events.js:95:17)
at net.js:441:14
at process._tickCallback (node.js:415:13)
4 Jan 01:47:40 - [nodemon] app crashed - waiting for file changes before starting...
I tried the troubleshooting as specified on the site : Updating Grunt, bower and cleaning npm and bower caches worked well. but updating npm gives an error too:
npm ERR! error rolling back Error: Refusing to delete: /usr/local/bin/npm not in /usr/local/lib/node_modules/npm
This looks like a conflict between homebrew and npm.
but anyway i have version 1.3.21 installed.
There is the same error when i am trying node server.
do you have an idea on what i can do to make the server work ?
It may be too easy, but seems like your MongoDB server is not actually running. After having installed Mongo (on your Mac, I assume?), you have to open a Terminal window/tab, run mongod and leave it running (or use screen, etc.). You can try to access MongoDB CLI by typing mongo to make sure the server is running.
#desgnl: if you don't want to run mongod command everytime you are running the grunt, you can always use third party services like MongoDB Hosting: Database-as-a-Service by MongoLab https://mongolab.com Hope this helps too!

Resources