Firebase Bcrypt Issue - node.js

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!

Related

EACCESS error when running meteor on Windows 10's VSCode

I tried to deploy my project, but this error still happens. I have restarted net driver, disabled Windows Defender, changed permission on my directory, let VSCode have admin right, but this error still persists. I could not even run on CMD with admin rights. I could deploy using WSL it takes a very long time for deployment. How can I fix this?
Error: EACCES: permission denied, stat 'C:\Users\mq003\Documents\myproject\.meteor\local\dev_bundle'
at Object.statSync (fs.js:1132:3)
at statOrNull (C:\Users\mq003\AppData\Local\.meteor\packages\meteor-tool\2.8.1\mt-os.windows.x86_64\tools\cli\dev-bundle.js:94:21)
at getDevBundleDir (C:\Users\mq003\AppData\Local\.meteor\packages\meteor-tool\2.8.1\mt-os.windows.x86_64\tools\cli\dev-bundle.js:32:25)
at Object.<anonymous> (C:\Users\mq003\AppData\Local\.meteor\packages\meteor-tool\2.8.1\mt-os.windows.x86_64\tools\cli\dev-bundle.js:142:20)
at Object.<anonymous> (C:\Users\mq003\AppData\Local\.meteor\packages\meteor-tool\2.8.1\mt-os.windows.x86_64\tools\cli\dev-bundle.js:145:3)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Module.require (internal/modules/cjs/loader.js:974:19) {
errno: -4092,
syscall: 'stat',
code: 'EACCES',
path: 'C:\\Users\\mq003\\Documents\\myproject\\.meteor\\local\\dev_bundle'
}
I see some options:
try deploy on docker.
restart winnat following this answer
https://stackoverflow.com/a/67968597/6398044
remove other processes on your meteor port (eg using kill-port npm package)
change port of your meteor app
Generally in linux this error is connected with access to files, but on windows it seems to be connected with network issues. In all other threads winnat is mentioned, so if this will not help please add more context about your winnat config.
Node.js port permission denied in Windows 10
https://superuser.com/questions/1437780/how-to-fix-listen-eacces-permission-denied-on-any-port
You can read about deployment meteor on windows here and compare it with your:
Deploy Meteor on Windows
https://forums.meteor.com/t/one-deployment-method-for-a-meteor-application-on-windows/13928

Nanoexpress server fails on Heroku & AWS - runs fine locally - cannot trace 'dest.on()' error

Relevant stack-trace below - from Heroku:
2020-04-28T17:49:11.997756+00:00 app[web.1]: Your app is listening on port 14385
2020-04-28T17:49:12.491486+00:00 heroku[web.1]: State changed from starting to up
2020-04-28T17:49:41.748150+00:00 heroku[web.1]: State changed from up to crashed
2020-04-28T17:49:41.649885+00:00 app[web.1]: _stream_readable.js:660
2020-04-28T17:49:41.649896+00:00 app[web.1]: dest.on('unpipe', onunpipe);
2020-04-28T17:49:41.649897+00:00 app[web.1]: ^
2020-04-28T17:49:41.649897+00:00 app[web.1]:
2020-04-28T17:49:41.649898+00:00 app[web.1]: TypeError: dest.on is not a function
2020-04-28T17:49:41.649899+00:00 app[web.1]: at ReadStream.Readable.pipe (_stream_readable.js:660:8)
2020-04-28T17:49:41.649900+00:00 app[web.1]: at SendStream.stream (/app/node_modules/send/index.js:798:10)
2020-04-28T17:49:41.649900+00:00 app[web.1]: at SendStream.send (/app/node_modules/send/index.js:707:8)
2020-04-28T17:49:41.649900+00:00 app[web.1]: at /app/node_modules/send/index.js:774:12
2020-04-28T17:49:41.649901+00:00 app[web.1]: at FSReqCallback.oncomplete (fs.js:172:5)
From AWS (EC2 using a Bitnami instance for NodeJS apps):
Your app is listening on port 8080
_stream_readable.js:666
dest.on('unpipe', onunpipe);
^
TypeError: dest.on is not a function
at ReadStream.Readable.pipe (_stream_readable.js:666:8)
at SendStream.stream (/opt/bitnami/apps/demo/htdocs/node_modules/send/index.js:798:10)
at SendStream.send (/opt/bitnami/apps/demo/htdocs/node_modules/send/index.js:707:8)
at /opt/bitnami/apps/coronavirus-demo/htdocs/node_modules/send/index.js:774:12
at FSReqCallback.oncomplete (fs.js:167:5)
error: Forever detected script exited with code: 1
error: Script restart attempt #1
I see that we seem to be dying on _stream_readable.js:666 where 'dest.on' isn't defined - and I'm way into the weeds of Node at this point - so I'm not sure what I'm looking for, but I find that we're defining this method further down in the file:
https://github.com/nodejs/node/blob/master/lib/_stream_readable.js:852 -
Is this as simple as we're evaluating this _stream_readable file top-down and we haven't defined on() as of line 666 and that's why it's failing?
But why would it work locally? The app runs fine with Nanoexpress server on a Macbook Pro - same package.json and lock files - no devDependencies that make any difference (the only devDependencies are like Mocha and Sinon and Chai for tests)
I've run the app locally with NODE_ENV=production and NPM_CONFIG_PRODUCTION=true (it's a React & Express [Nanoexpress] app) and it boots and I can get what I need running just fine.
It's only when I push to Heroku / AWS that I'm getting this failure. Feels like we're trying to use a function before it's defined...
nanoexpress author here.
nanoexpress works fine on Heroku on my projects, but on AWS did not test, but nanoexpress does not support Lambda/Serverless.
Please check first your code or try PRO version as now it's Free

Cloud Functions of Firebase failed to emulate

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

How to release resource \AppData\Local\Temp\shelljs_60d55c70cdc922162f4b without removing antivirus or reinstalling node?

I'm running Ionic2 to build windows app. but it is giving me following error:
shell.js: internal error
Error: EBUSY: resource busy or locked, open 'C:\Users\edge\AppData\Local\Temp\shelljs_60d55c70cdc922162f4b'
at Error (native)
at Object.fs.openSync (fs.js:640:18)
at Object.fs.writeFileSync (fs.js:1333:33)
at execSync (C:\Users\edge\AppData\Roaming\npm\node_modules\ionic\node_modules\shelljs\src\exec.js:67:57)
at Object._exec (C:\Users\edge\AppData\Roaming\npm\node_modules\ionic\node_modules\shelljs\src\exec.js:179:12)
at Object.exec (C:\Users\edge\AppData\Roaming\npm\node_modules\ionic\node_modules\shelljs\src\common.js:168:23)
at Object.gatherGulpInfo (C:\Users\edge\AppData\Roaming\npm\node_modules\ionic\node_modules\ionic-app-lib\lib\info.js:201:24)
at Object.t (C:\Users\edge\AppData\Roaming\npm\node_modules\ionic\lib\utils\stats.js:148:15)
at Object.run (C:\Users\edge\AppData\Roaming\npm\node_modules\ionic\lib\cli.js:135:16)
at Object.<anonymous> (C:\Users\edge\AppData\Roaming\npm\node_modules\ionic\bin\ionic:13:10)
I sow a same error:
Ionic run android - Internal Error
But I don't want to remove my antivirus and reinstall nodeJS.
But when I restart my system and immediately after I run the command It works(Possibly some process takes time to execute which one access this resource)
Snapshot of process running on my system are as follows:
I faced the same issue , and resolved it by uninstalling bytefence anti malware . it actually use the same resource mentioned above .(I checked in dell laptop)

Node with Opa app crashes when trying to connect to unavailable CouchDB

I am working on Opa app using CouchDB as a database backend. When fetching a document with API function CouchDd.Document.get (API doc) and the DB server is down, my app crashed:
/opt/mlstate/lib/opa/stdlib/server.opp/serverNodeJsPackage.js:169
,(global.hasOwnProperty("toString") && global.toString || undefined)(e));}req.
^
TypeError: undefined is not a function
at ClientRequest.on_error (/opt/mlstate/lib/opa/stdlib/server.opp/serverNodeJsPackage.js:169:489)
at ClientRequest.EventEmitter.emit (events.js:88:17)
at Socket.socketErrorListener (http.js:1320:9)
at Socket.EventEmitter.emit (events.js:88:17)
at Socket._destroy.self.errorEmitted (net.js:329:14)
at process.startup.processNextTick.process._tickCallback (node.js:244:9)
and returns to shell prompt. I am running the app with ./myapp --nodb, because I do not use the build-in support for the MongoDB.
The CouchDb.Document.get function returns either {success: {FormatedJson: ...}} or {failure}. I expected that parsing the result for the {failure} is enough to catch all the network connection problems. What else should I do?
I am using Opa framework version 1.0.5 on OSX (11.4.0 Darwin) from the standard package on the Opa website, Node.js v0.8.3 and CouchDB 1.2.0.
This was a bug in 1.0.5, but it's been fixed already. You can get the sources for the fixed version here, but an official package hasn't been released yet.

Resources