How to firebase deploy through Bitbucket Pipeline? - firebase

I am using angular-cli project and I used Heroku for CD integration. And the repository is on Bitbucket.
Now I am going to use firebase deploy service through Bithubcket pipeline, so I tried as below.
package.json
{
"name": "mail-activator",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"postinstall": "ng build --prod",
"deploy": "firebase deploy --token $FIREBASE_TOKEN",
"start": "node server.js"
},
"private": true,
"dependencies": {
"#angular/animations": "^4.1.3",
"#angular/cli": "1.0.3",
"#angular/common": "^4.1.3",
"#angular/compiler": "^4.1.3",
"#angular/compiler-cli": "^4.1.3",
"#angular/core": "^4.1.3",
"#angular/forms": "^4.1.3",
"#angular/http": "^4.1.3",
"#angular/material": "^2.0.0-beta.5",
"#angular/platform-browser": "^4.1.3",
"#angular/platform-browser-dynamic": "^4.1.3",
"#angular/router": "^4.1.3",
"angular2-prettyjson": "^2.0.5",
"angularfire2": "^4.0.0-rc.0",
"bootstrap": "^4.0.0-alpha.6",
"core-js": "^2.4.1",
"express": "^4.15.3",
"firebase": "^4.0.0",
"firebase-tools": "^3.9.0",
"hammerjs": "^2.0.8",
"ng2-sweetalert2": "0.0.8",
"ngx-validators": "^3.0.0",
"promise-polyfill": "^6.0.2",
"rxjs": "^5.4.0",
"sweetalert2": "^6.6.3",
"zone.js": "^0.8.11"
},
"devDependencies": {
"#angular/cli": "1.0.3",
"#angular/compiler-cli": "^4.1.3",
"#types/jasmine": "2.5.47",
"#types/node": "~7.0.22",
"codelyzer": "~3.0.1",
"jasmine-core": "~2.6.2",
"jasmine-spec-reporter": "~4.1.0",
"karma": "~1.7.0",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~3.0.4",
"tslint": "~5.3.0",
"typescript": "~2.3.3"
}
}
and This is Bitbucket pipeline script.
image: node:7.6.0
pipelines:
default:
- step:
script: # Modify the commands below to build your repository.
- npm install
- npm run postinstall
- npm run deploy
I tried this, but it says
i functions: preparing functions directory for uploading...
Error: Error parsing triggers: Cannot find module 'firebase-functions'
Try running "npm install" in your functions directory before deploying.
I am not sure if the bitbucket pipe line uses docker or some container? On Travis we installed firebase-tools as global.
npm install -g firebase-tools
But I am not sure it will works on bitbucket pipeline.
Any helps are welcomed.

Try using another image. There's an example that uses both angular cli and firebase tool for it. So you do something like:
image: gabrielaraujof/angular-cli
pipelines:
default:
- step:
script: # Modify the commands below to build your repository.
- npm install
- ng build
- ng test --watch=false
- firebase deploy --token=$FIREBASE_TOKEN --project project-name-firebase --non-interactive
You get the "$FIREBASE_TOKEN" on firebasetool by running:
firebase login:ci
Save it on bit bucket's Environment variables(Settings > Environment variables) and run the pipeline

Related

Vercel deployment throws "Error: Cannot find module '#next/env'"

I've been trying to debug this error for so long now... Screenshot from Vercel I have a .env file in my root directory. I'm completely new to web deployment so I wasn't quite sure about what to put in the .env file either. The directory which Vercel's error message points to /vercel/path0/node_modules/next-sitemap/bin/next-sitemap isn't even a directory in my root folder for this project.
EDIT: This is the project's file structure. File Structure
EDIT2: The package.json file
"name": "landing-page",
"version": "0.0.1",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build && next export",
"postbuild": "next-sitemap"
},
"dependencies": {
"#next/bundle-analyzer": "^12.0.7",
"dotenv": "^8.6.0",
"file-loader": "^6.2.0",
"framer-motion": "^2.7.5",
"globby": "^11.0.0",
"isomorphic-unfetch": "^3.0.0",
"next": "9.5.3",
"next-compose-plugins": "^2.2.0",
"next-optimized-images": "^2.5.4",
"npm": "^8.2.0",
"prettier": "^2.1.2",
"rc-drawer": "^4.1.0",
"react": "16.13.0",
"react-custom-scrollbars": "^4.2.1",
"react-dom": "16.13.0",
"react-ga": "^3.1.2",
"react-icons": "^3.10.0",
"react-modal-video": "^1.2.6",
"react-multi-carousel": "^2.5.5",
"react-scroll": "^1.8.0",
"react-stickynode": "^3.0.3",
"theme-ui": "^0.3.1",
"typeface-dm-sans": "^1.1.3",
"webpack": "^4.46.0"
},
"devDependencies": {
"imagemin-mozjpeg": "^9.0.0",
"imagemin-optipng": "^8.0.0",
"imagemin-svgo": "^8.0.0",
"next-sitemap": "^1.6.203",
"webpack-cli": "^4.9.1"
}
}
Your project does not have package-lock.json file. This most likely causes the error.
Remove node_modules directory from your root project directory.
Below is an example of how the project should look like.
Run npm install again.
Now you should have the package-lock.json file in your root project directory.
Try to deploy your app without any issue.

Error! You've attempted to require '#react-native-firebase/auth' version '6.2.0', however

Error! You've attempted to require #react-native-firebase/auth version '6.2.0', however, the #react-native-firebase/app module is of a different version (6.3.4).
I get this error whenever I launch the app. I've tried to reinstall all the modules, to delete and reinstall, to install all react native firebase modules to version 6.3.4, to version 6.2.0 but still nothing.
I can't use the firebase package because I've implemented firebase differently.
Do you have any idea what should I do?
Package.json:
"name": "Vanto",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"#react-native-firebase/app": "^6.2.0",
"#react-native-firebase/auth": "^6.2.0",
"#react-native-firebase/storage": "^6.2.0",
"#types/react": "^16.9.17",
"#types/react-native": "^0.60.31",
"jetifier": "^1.6.5",
"react": "16.9.0",
"react-native": "0.61.5",
"react-native-admob": "^2.0.0-beta.6",
"react-native-appearance": "^0.3.1",
"react-native-gesture-handler": "^1.5.3",
"react-native-image-picker": "^2.3.0",
"react-native-ionicons": "^4.6.4",
"react-native-navigation-bar-color": "^1.0.0",
"react-native-reanimated": "^1.4.0",
"react-native-restart": "0.0.14",
"react-native-splash-screen": "^3.2.0",
"react-native-typescript-transformer": "^1.2.13",
"react-native-vector-icons": "^6.6.0",
"react-navigation": "^4.0.10",
"react-navigation-stack": "^1.10.3",
"react-navigation-tabs": "^2.6.2",
"styled-components": "^5.0.1",
"typescript": "^3.7.5",
"uninstall": "0.0.0"
},
"devDependencies": {
"#babel/core": "^7.6.2",
"#babel/runtime": "^7.6.2",
"#react-native-community/eslint-config": "^0.0.5",
"babel-jest": "^24.9.0",
"eslint": "^6.5.1",
"jest": "^24.9.0",
"metro-react-native-babel-preset": "^0.56.0",
"react-test-renderer": "16.9.0"
},
"jest": {
"preset": "react-native"
}
}
Fixed by cleaning node cache and yarn cache as well as reinstalling react native firebase modules all in 6.2.0

Issue using firebase-admin - dependencies were not found

I am developing an application by nuxtjs. I have installed the Admin SDK for Node.js to validate the user's token in the server side but when I import firebase-admin in the project I have the next issue. I have installed the modules child_process fs net tls but it didn' work.
WARNING Compiled with 4 warnings
20:30:20 warning in ./node_modules/grpc/src/grpc_extension.js
Critical dependency: the request of a dependency is an expression
warning in
./node_modules/grpc/node_modules/node-pre-gyp/lib/pre-binding.js
Critical dependency: the request of a dependency is an expression
warning in
./node_modules/grpc/node_modules/node-pre-gyp/lib/util/versioning.js
Critical dependency: the request of a dependency is an expression
warning in ./node_modules/hash-stream-validation/index.js
Module not found: Error: Can't resolve 'fast-crc32c' in
'C:\Users\ARSENIO\Desktop\Development\nuxt\project4\node_modules\hash-stream-
validation'
ERROR Failed to compile with 38 errors
20:30:20 These dependencies were not found:
child_process in ./node_modules/google-auth-library/build/src/auth/googleauth.js,
./node_modules/grpc/node_modules/detect-libc/lib/detect-libc.js
fs in ./node_modules/#google-cloud/storage/src/file.js, ./node_modules/#google-cloud/storage/src/bucket.js and 34 others
To install them, you can run: npm install --save child_process fs
The package.json file is:
{
"name": "project4",
"version": "1.0.0",
"description": "My gnarly Nuxt.js project",
"author": "Arsenio Aguirre",
"private": true,
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate",
"lint": "eslint --ext .js,.vue --ignore-path .gitignore .",
"precommit": "npm run lint"
},
"dependencies": {
"bootstrap": "^4.1.3",
"bootstrap-vue": "^2.0.0-beta",
"chart.js": "^2.7.2",
"child_process": "^1.0.2",
"cross-env": "^5.2.0",
"firebase": "^5.5.3",
"firebase-admin": "^6.0.0",
"flag-icon-css": "^2.9.0",
"font-awesome": "^4.7.0",
"fs": "0.0.1-security",
"js-cookie": "^2.2.0",
"net": "^1.0.2",
"node-sass": "^4.9.3",
"nuxt": "^2.0.0",
"sass-loader": "^6.0.7",
"simple-line-icons": "^2.4.1",
"tls": "0.0.1",
"vue-chartjs": "^3.4.0"
},
"devDependencies": {
"nodemon": "^1.11.0",
"babel-eslint": "^8.2.1",
"eslint": "^5.0.1",
"eslint-loader": "^2.0.0",
"eslint-plugin-vue": "^4.0.0",
"eslint-config-prettier": "^3.1.0",
"eslint-plugin-prettier": "2.6.2",
"prettier": "1.14.3"
}
}

cannot find module "firebase-functions"

I imported and downloaded: firebase-functions and firebase-admin using npm i <package> but it give me a lint error like: cannot find module "firebase-functions". I also restarted vscode, but problem persists..
Could it be problem with webpack or tsconfig?
Some important packages in package.json:
{
"dependencies": {
"#angular/animations": "^5.2.3",
"#angular/cdk": "^5.1.1",
"#angular/common": "^5.2.2",
"#angular/compiler": "^5.2.2",
"#angular/core": "^5.2.2",
"#angular/forms": "^5.2.2",
"#angular/http": "^5.2.2",
"#angular/material": "^5.0.2",
"#angular/material-moment-adapter": "^5.2.3",
"#angular/platform-browser": "^5.2.2",
"#angular/platform-browser-dynamic": "^5.2.2",
"#angular/platform-server": "^5.2.3",
"#angular/router": "~5.2.2",
"core-js": "^2.5.3",
"express": "^4.16.2",
"firebase": "^4.9.1",
"firebase-admin": "~5.8.1",
"firebase-functions": "^0.8.1",
"zone.js": "0.8.18"
},
"private": true,
"devDependencies": {
"#angular/cli": "^1.6.7",
"#angular/compiler-cli": "^5.2.2",
"#angular/language-service": "^4.2.4",
"#types/jasmine": "~2.5.53",
"#types/jasminewd2": "~2.0.2",
"#types/node": "~6.0.60",
"angular-universal-express-firebase": "0.0.4",
"babel-preset-es2015": "^6.24.1",
"codelyzer": "~3.1.1",
"jasmine-core": "~2.6.2",
"jasmine-spec-reporter": "~4.1.0",
"karma": "~1.7.0",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"npm-run-all": "^4.1.2",
"protractor": "~5.1.2",
"ts-loader": "^3.4.0",
"ts-node": "~3.2.0",
"tslint": "~5.3.2",
"typescript": "^2.4.2",
"webpack": "^3.8.1",
"webpack-node-externals": "^1.6.0"
}
}
npm install firebase-functions
npm install firebase-admin
You can try the following commands:
firebase use --add
firebase init functions
To get your project. Sometimes, its a permission problem. What you can try is creating a new account on your computer and doing the same commands, that almost always works.
I handled this problem with these steps. I don't really know whether exact solution is delete and initialize firebase functions again. Also I thought that problem is not specific only firebase-functions or firebase-admin. It can be missing node_modules packages.
delete node_modules in functions
firebase init functions. Update tsconfig and package.json and install dependencies.
restart vscode
#Shaybakov answer was the solution to my problem.
I recently switched the location of my project on my local machine. This meant that firebase libraries were not imported into the local directory and I either had to reconfigure the entire firebase CLl or just manually update the firebase libraries in the local directory with the commands that #Shaybakov stated.
npm install firebase-functions
npm install firebase-admin
step 1. npm install firebase-admin
step 2. npm install firebase-functions

Ionic 2 : Firebase Cloud Messaging and Google services errors

I have tried searching at a ton of places to get FCM working. I am using Google Authentication API and have just installed FCM to use Push Notifications. I would like to use both of them. When i do build I get these errors.
* What went wrong:
A problem occurred evaluating root project 'android'.
Failed to apply plugin [class 'com.google.gms.googleservices.GoogleServicesPlugin']
BUILD FAILED
Total time: 3.002 secs
> For input string: "+"
This is my project.properties file
target=android-25
android.library.reference.1=CordovaLib
cordova.system.library.1=com.facebook.android:facebook-android-sdk:4.+
cordova.system.library.2=com.google.android.gms:play-services-auth:+
cordova.system.library.3=com.google.android.gms:play-services-identity:+
cordova.system.library.4=com.android.support:support-v13:25.1.0
cordova.system.library.5=me.leolin:ShortcutBadger:1.1.17#aar
cordova.system.library.6=com.google.firebase:firebase-messaging:11.0.1
cordova.gradle.include.1=phonegap-plugin-push/starter-push.gradle
Couple of things I tried after reading lot of posts:
1. I removed and added android platform then did the build.
2. I tried changing the versions of below libraries to numerous values, but it does not help.
cordova.system.library.2=com.google.android.gms:play-services-auth:+
cordova.system.library.3=com.google.android.gms:play-services-identity:+
If try changing the version from + to 3.0.0 or 9.8.0 or any version I get this error for firebase
* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':_debugApkCopy'.
> Could not find com.google.firebase:firebase-messaging:11.0.1.
Required by:
project :
Note: Changing the same inside the build.gradle file dosen't help as it gets overridden when we do a build.
this is my package.json.
{
"name": "test",
"version": "0.0.1",
"author": "Ionic Framework",
"homepage": "http://ionicframework.com/",
"private": true,
"scripts": {
"clean": "ionic-app-scripts clean",
"build": "ionic-app-scripts build",
"lint": "ionic-app-scripts lint",
"ionic:build": "ionic-app-scripts build",
"ionic:serve": "ionic-app-scripts serve",
"start": "node ./bin/www"
},
"dependencies": {
"#angular/common": "4.1.2",
"#angular/compiler": "4.1.2",
"#angular/compiler-cli": "4.1.2",
"#angular/core": "4.1.2",
"#angular/forms": "4.1.2",
"#angular/http": "4.1.2",
"#angular/platform-browser": "4.1.2",
"#angular/platform-browser-dynamic": "4.1.2",
"#ionic-native/core": "3.10.2",
"#ionic-native/facebook": "^3.10.2",
"#ionic-native/google-plus": "^3.12.1",
"#ionic-native/native-storage": "^3.10.3",
"#ionic-native/splash-screen": "3.10.2",
"#ionic-native/status-bar": "3.10.2",
"#ionic/storage": "2.0.1",
"body-parser": "^1.17.2",
"cordova-android": "^6.2.3",
"cordova-plugin-console": "^1.0.5",
"cordova-plugin-device": "^1.1.4",
"cordova-plugin-facebook4": "^1.9.0",
"cordova-plugin-googleplus": "^5.1.1",
"cordova-plugin-nativestorage": "^2.2.2",
"cordova-plugin-splashscreen": "^4.0.3",
"cordova-plugin-statusbar": "^2.2.2",
"cordova-plugin-whitelist": "^1.3.1",
"express": "^4.15.3",
"ionic-angular": "3.3.0",
"ionic-native": "^2.5.1",
"ionic-plugin-keyboard": "^2.2.1",
"ionicons": "3.0.0",
"mongoose": "^4.11.4",
"morgan": "^1.8.2",
"phonegap-plugin-push": "^2.0.0",
"rxjs": "5.1.1",
"serve-favicon": "^2.4.3",
"socket.io": "^2.0.3",
"socket.io-client": "^2.0.3",
"sw-toolbox": "3.6.0",
"zone.js": "0.8.11"
},
"devDependencies": {
"#ionic/app-scripts": "1.3.7",
"#ionic/cli-plugin-cordova": "1.6.2",
"#ionic/cli-plugin-ionic-angular": "1.4.1",
"ionic": "3.7.0",
"typescript": "2.3.3"
},
"description": "An Ionic project",
"cordova": {
"plugins": {
"cordova-plugin-console": {},
"cordova-plugin-device": {},
"cordova-plugin-splashscreen": {},
"cordova-plugin-statusbar": {},
"cordova-plugin-whitelist": {},
"ionic-plugin-keyboard": {},
"cordova-plugin-facebook4": {
"APP_ID": "xxxxxxx2",
"APP_NAME": "test"
},
"cordova-plugin-googleplus": {
"REVERSED_CLIENT_ID": "4xxxxxxxx6-7dsgct91usuntkmomme1n8rq5i7oipq8.apps.googleusercontent.com"
},
"phonegap-plugin-push": {
"SENDER_ID": "81xxxxx8690"
}
},
"platforms": [
"android"
]
},
"main": "index.js",
"keywords": [
"server"
],
"license": "ISC"
}
Can some one please help me out, suggest a better approach to implement Push notification. Thanks in advance!
Try to install Google Repository
Tools -> SDK Manager -> Google Repository
https://i.stack.imgur.com/qe8iu.png

Resources