this.getOptions not found in react-native-firebase - firebase

When integrating react-native-firebase within my native app, I am facing following error while launching the application
Module build failed (from ./node_modules/babel-loader/lib/index.js):
TypeError: this.getOptions is not a function
at Object.loader (/Users/nikhilfarheen/Documents/ReactComponent/sharespecs/node_modules/babel-loader/lib/index.js:46:28)
at Object.<anonymous> (/Users/nikhilfarheen/Documents/ReactComponent/sharespecs/node_modules/babel-loader/lib/index.js:41:12)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
packages installed are
"dependencies": {
"#babel/plugin-transform-react-jsx": "^7.20.7",
"#react-native-firebase/app": "^16.5.0",
"#react-native-firebase/messaging": "^16.5.0",
"babel": "^6.23.0",
"babel-core": "^6.26.3",
"babel-loader": "^9.1.2",
"firebase": "^9.15.0",
"link": "^1.5.1",
"react-native": "^0.71.0",
"react-native-cli": "^2.0.1",
"react-native-device-info": "^10.3.0",
"style-loader": "2.0.0",
"webpack-stream": "^7.0.0"
}
Tried installing peer dependencies of other packages like webpack but nothing worked

You have missed downloading dependencies.
Follow below steps to install dependencies mentioned in their official doc
Run npm uninstall babel-loader
Run npm install -D babel-loader #babel/core #babel/preset-env webpack

Related

Deploying Firebase functions with a shared package shows errors about conflicting lockfiles

I am working off a monorepo with folders
/front
/back
/shared
I am trying to deploy my backend functions to Firebase.
I can run them on Firebase emulator nicely locally. However, when trying to deploy them online, I am faced with this error:
...
i deploying functions
i functions: preparing codebase default for deployment
i functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i functions: ensuring required API cloudbuild.googleapis.com is enabled...
i artifactregistry: ensuring required API artifactregistry.googleapis.com is enabled...
✔ functions: required API cloudfunctions.googleapis.com is enabled
✔ functions: required API cloudbuild.googleapis.com is enabled
✔ artifactregistry: required API artifactregistry.googleapis.com is enabled
i functions: Loaded environment variables from .env.
i functions: preparing functions directory for uploading...
i functions: packaged $PROJECT_PATH/MYPROJECT/back/functions (2.39 MB) for uploading
✔ functions: functions folder uploaded successfully
i functions: creating Node.js 18 function api(us-central1)...
Build failed: npm ERR! code EUSAGE
npm ERR!
npm ERR! `npm ci` can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with `npm install` before continuing.
npm ERR!
npm ERR! Invalid: lock file's #MYPROJECT/shared#1.0.0 does not satisfy #MYPROJECT/shared#
npm ERR! Missing: #MYPROJECT/shared# from lock file
npm ERR!
npm ERR! Clean install a project
npm ERR!
npm ERR! Usage:
npm ERR! npm ci
npm ERR!
...
In back/functions/package.json, I have this:
"dependencies": {
"#MYPROJECT/shared": "file:../../shared",
"cors": "^2.8.5",
"dotenv": "^16.0.3",
"express": "^4.18.2",
"firebase-admin": "^11.5.0",
"firebase-functions": "^4.2.1",
"got": "^11.8.2",
"openai": "^2.0.5",
"serialize-error": "^11.0.0",
"vite": "^4.0.4",
"vitest": "^0.28.3"
},
And in shared/package.json
"devDependencies": {
"#types/jest": "^29.1.2",
"#types/node": "^18.8.5",
"#typescript-eslint/eslint-plugin": "^5.38.0",
"#typescript-eslint/parser": "^5.38.0",
"#vitest/coverage-c8": "^0.28.3",
"eslint": "^8.23.1",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-airbnb-typescript": "^17.0.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-prettier": "^4.2.1",
"prettier": "^2.7.1",
"typescript": "^4.8.4",
"vite": "^4.0.4",
"vitest": "^0.28.3"
}
}
In back/firebase.json I have this:
{
"source": "functions",
"functions": {
"predeploy": "npm --prefix functions run build"
}
}
I tried reinstalling everything like this:
cd $PROJECT_PATH/MYPROJECT/shared
rm -r node_modules; rm package-lock.json; npm cache clean --force
cd $PROJECT_PATH/MYPROJECT/back/functions
rm -r node_modules; rm package-lock.json; npm cache clean --force
npm install
cd $PROJECT_PATH/MYPROJECT/shared
npm install
cd $PROJECT_PATH/MYPROJECT/back/
firebase functions:delete api; firebase deploy --only functions
But I still get the same error.
Any other suggestions on what could be the issue?

EAS build error when reaching "install dependencies"

I've started using react native with expo not long ago so I am a bit lost.
When trying to build the application with the command:
eas build --profile development --platform android
The build fails when it reaches the install dependencies part
Running "npm install" in the root dir of your repository 2[stderr] npm ERR! code ERESOLVE3[stderr] npm ERR!4[stderr] ERESOLVE could not resolve5[stderr] npm ERR! 6[stderr] npm ERR!7[stderr] While resolving: #react-native-firebase/auth#16.2.08[stderr] npm ERR! Found: #react-native-firebase/app#15.4.09[stderr] npm ERR! node_modules/#react-native-firebase/app10[stderr] npm ERR! #react-native-firebase/app#"~15.4.0" from the root project11[stderr] npm ERR! 12[stderr] npm ERR! Could not resolve dependency:13[stderr] npm ERR! peer #react-native-firebase/app#"16.2.0" from #react-native-firebase/auth#16.2.014[stderr] npm ERR! node_modules/#react-native-firebase/auth15[stderr] npm ERR! #react-native-firebase/auth#"^16.2.0" from the root project16[stderr] npm17[stderr] ERR! 18[stderr] npm ERR! Conflicting peer dependency: #react-native-firebase/app#16.2.019[stderr] npm ERR! node_modules/#react-native-firebase/app20[stderr] npm ERR! peer #react-native-firebase/app#"16.2.0" from #react-native-firebase/auth#16.2.021[stderr] npm ERR! node_modules/#react-native-firebase/auth22[stderr] npm ERR! #react-native-firebase/auth#"^16.2.0" from the root project23[stderr] npm ERR! 24[stderr] npm ERR! Fix the upstream dependency conflict, or retry25[stderr] npm ERR! this command with --force, or --legacy-peer-deps26[stderr] npm ERR! to accept an incorrect (and potentially broken) dependency resolution.27[stderr] npm ERR! 28[stderr] npm ERR! See /home/expo/.npm/eresolve-report.txt for a full report.29[stderr] 30[stderr] npm ERR! A complete log of this run can be found in:31[stderr] npm ERR! /home/expo/.npm/_logs/2022-11-26T18_50_07_398Z-debug-0.log32npm exited with non-zero code: 1
I have tried clearing the cache and rebuilding the app. When I try npx expo start --dev-client the app works fine.
This is my package.json:
{
"name": "wallet",
"version": "1.0.0",
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web"
},
"dependencies": {
"#react-native-firebase/app": "~15.4.0",
"#react-native-firebase/auth": "^16.2.0",
"#react-native-google-signin/google-signin": "^8.0.1",
"#react-navigation/bottom-tabs": "^6.4.0",
"#react-navigation/drawer": "^6.5.0",
"#react-navigation/material-top-tabs": "^6.3.0",
"#react-navigation/native": "^6.0.13",
"#react-navigation/native-stack": "^6.9.1",
"#rneui/base": "^4.0.0-rc.7",
"#rneui/themed": "^4.0.0-rc.7",
"expo": "~46.0.16",
"expo-dev-client": "~1.3.1",
"expo-font": "~10.2.0",
"expo-linear-gradient": "~11.4.0",
"expo-local-authentication": "~12.3.0",
"expo-status-bar": "~1.4.0",
"formik": "^2.2.9",
"moment": "^2.29.4",
"react": "18.0.0",
"react-native": "0.69.6",
"react-native-gesture-handler": "~2.5.0",
"react-native-icon-badge": "^1.1.3",
"react-native-linear-gradient": "^2.6.2",
"react-native-pager-view": "^5.4.24",
"react-native-reanimated": "~2.9.1",
"react-native-recaptcha-that-works": "^1.3.2",
"react-native-safe-area-context": "^4.3.1",
"react-native-screens": "~3.15.0",
"react-native-tab-view": "^3.3.0",
"react-native-webview": "11.23.0",
"styled-components": "^5.3.6"
},
"devDependencies": {
"#babel/core": "^7.12.9"
},
"private": true
}
I come a cross the same issue today while building for production. I solved with installing dependencies by:
yarn install
After that eas switced to yarn instead of using npm to install the packages. Hope its works for you.
After digging into the specific missing or conflicting dependencies, I managed to fix the issue by:
deleting node_modules (from terminal) with rm -rf node_modules.
update react to version 18.1.0
Install react-dom 18.1.0
After all that, I managed to build the app with EAS, but after I launched it, it instantly crashed with no errors on my device.
after debugging my device errors by connecting it to my PC,
I saw that some of my expo dependencies are not updated, so I used the following:
expo doctor --fix dependencies.
After that, the app was finally. launching correctly
Thank you, #Kaosc, for leading me to this fix.
Some of the things above might not be connected, but that's what I did.
I did this in my terminal in the root of my project:
expo doctor
It gave me this:
Expected package #expo/config-plugins#^5.0.2
Found invalid:
#expo/config-plugins#4.0.6
(for more info, run: npm why #expo/config-plugins)
Some dependencies are incompatible with the installed expo package version:
- expo-status-bar - expected version: ~1.4.2 - actual version installed: 1.2.0
- expo-updates - expected version: ~0.15.6 - actual version installed: 0.11.7
- react - expected version: 18.1.0 - actual version installed: 18.2.0
- react-dom - expected version: 18.1.0 - actual version installed: 17.0.1
- react-native - expected version: 0.70.5 - actual version installed: 0.70.6
- react-native-reanimated - expected version: ~2.12.0 - actual version installed: 2.13.0
- react-native-safe-area-context - expected version: 4.4.1 - actual version installed: 3.3.2
- react-native-screens - expected version: ~3.18.0 - actual version installed: 3.10.2
- react-native-web - expected version: ~0.18.9 - actual version installed: 0.17.1
- react-native-webview - expected version: 11.23.1 - actual version installed: 11.15.0
Your project may not work correctly until you install the correct versions of the packages.
To install the correct versions of these packages, please run: expo doctor --fix-dependencies,
or install individual packages by running expo install [package-name ...]
Then I did this:
expo doctor --fix-dependencies
Then I go this and no more errors:
Expected package #expo/config-plugins#^5.0.2
Found invalid:
#expo/config-plugins#4.0.6
(for more info, run: npm why #expo/config-plugins)
Some dependencies are incompatible with the installed expo package version:
- expo-status-bar - expected version: ~1.4.2 - actual version installed: 1.2.0
- expo-updates - expected version: ~0.15.6 - actual version installed: 0.11.7
- react - expected version: 18.1.0 - actual version installed: 18.2.0
- react-dom - expected version: 18.1.0 - actual version installed: 17.0.1
- react-native - expected version: 0.70.5 - actual version installed: 0.70.6
- react-native-reanimated - expected version: ~2.12.0 - actual version installed: 2.13.0
- react-native-safe-area-context - expected version: 4.4.1 - actual version installed: 3.3.2
- react-native-screens - expected version: ~3.18.0 - actual version installed: 3.10.2
- react-native-web - expected version: ~0.18.9 - actual version installed: 0.17.1
- react-native-webview - expected version: 11.23.1 - actual version installed: 11.15.0
This command is being executed with the global Expo CLI. Learn more: https://blog.expo.dev/the-new-expo-cli-f4250d8e3421
To use the local CLI instead (recommended in SDK 46 and higher), run:
› npx expo install
Installing 10 SDK 47.0.0 compatible native modules using npm.
> npm install
added 10 packages, removed 97 packages, changed 33 packages, and audited 1216 packages in 2m
57 packages are looking for funding
run `npm fund` for details
7 vulnerabilities (1 low, 5 high, 1 critical)
To address issues that do not require attention, run:
npm audit fix
To address all issues (including breaking changes), run:
npm audit fix --force
Run `npm audit` for details.
Delete package-lock.json and try again

npm ERR! peer dep missing: firebase-admin#^7.0.0, required by firebase-functions#2.3.1

I am trying to understand how to get the version of firebase-admin that is required. My scenario is this:
MYPATH\functions>npm list firebase-admin
functions# MYPATH\functions
`-- UNMET PEER DEPENDENCY firebase-admin#6.5.1
npm ERR! peer dep missing: firebase-admin#^7.0.0, required by firebase-functions#2.3.1
Running npm update firebase-admin does not change anything.
package.json contains this line:
"dependencies": {
...
"firebase-admin": "^6.5.1",
What am I supposed to do?
UPDATE:
When doing firebase serve I get this error:
! Your requested "node" version "6" doesn't match your global version "10"
....
+ hosting: Local server: http://localhost:5000
! The Cloud Functions emulator requires the module "firebase-admin" to be installed. This package is in your package.json, but it's not available. You probably need to run "npm install" in your functions directory.
i functions: Your functions could not be parsed due to an issue with your node_modules (see above)
'npm update' is working, however the '^' carat against "firebase-admin" in your package.json will limit the updates to the 6.x releases - so it's not getting anything newer then the 6.5.1 release.
You can manually change the version of "firebase-admin" in your package.json to "^7.0.0" and then run 'npm install'. This will grab the latest release in the 7.x.x range.

error code ELIFECYCLE errno 1 error functions# lint: `eslint .` while deploying firebase [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
i am trying to deploy my function to the firebase but when ever i execute
firebase deploy
i do get the error.
C:\Users\vimiv>firebase deploy
=== Deploying to 'touch-keeper'...
i deploying functions, hosting
Running command: npm --prefix "%RESOURCE_DIR%" run lint
> functions# lint C:\Users\vimiv\functions
> eslint .
module.js:549
throw err;
^
Error: Cannot find module 'wordwrap'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (C:\Users\vimiv\functions\node_modules\optionator\lib\help.js:6:14)
at Object.<anonymous> (C:\Users\vimiv\functions\node_modules\optionator\lib\help.js:247:4)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! functions# lint: `eslint .`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the functions# lint script.
npm ERR! This is probably not a problem with npm. There is likely additional
logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\vimiv\AppData\Roaming\npm-cache\_logs\2018-08-
17T10_47_41_587Z-debug.log
Error: functions predeploy error: Command terminated with non-zero exit code1
here is my index.js
'use-strict'
const admin = require('firebase-admin');
const functions = require('firebase-functions');
admin.initializeApp(functions.config().firebase);
exports.sendMessageNotification = functions.database.ref('DR/MELTING/{itemname}').onWrite(event => {
//const itemname = event.params.itemname;
console.log("Notificatiion Triggered Successfuly");
});
here is my package.json
{
"name": "functions",
"description": "Cloud Functions for Firebase",
"scripts": {
"lint": "eslint .",
"serve": "firebase serve --only functions",
"shell": "firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"dependencies": {
"firebase-admin": "^6.0.0",
"firebase-functions": "^2.0.5",
"prelude-ls": "^1.1.2",
"word-wrap": "^1.2.3"
},
"devDependencies": {
"eslint": "^4.12.0",
"eslint-plugin-promise": "^3.6.0"
},
"private": true
}
And also i changed my firebase.json prefix command
You need to install any dependency you may be using in your function. Run npm install inside your functions folder.
Try with npm install -g word-wrap and after firebase deploy.

Firebase can't find Bolt

Update: Seems to have been fixed somewhere between firebase-tools 3.0.6 and 3.2.0
Recently firebase deploy has stopped working because it thinks that Bolt is not installed. It is installed both locally and globally. I've tried updating, uninstalling, manually deleting, reinstalling, and updating again in both location and it always gives the same error:
>firebase deploy
Error: There was an error loading firebase.json:
Bolt not installed, run npm install -g firebase-bolt
According to npm, firebase 3.2.1, firebase-tools 3.0.6 and firebase-bolt 0.8.1 are installed globally.
Contents of firebase.json:
{
"public": "web",
"rules": "rules.bolt",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
]
}
This is a known issue. Have a look here:
firebase-bolt not found on Windows #205
and test the package mentioned:
npm install -g oscar-b/firebase-tools

Resources