Firebase Next.js Hosting: Unable to find 'esbuild' - firebase

I'm trying to use Firebase's new Next.js support for Hosting (see https://firebase.google.com/docs/hosting/nextjs) but I'm getting a weird error when I try to deploy. (Everything runs correctly in the local emulator suite, btw)
Screenshot of Console output with error
When I try to run firebase deploy --only hosting,functions -m "testing out next.js support" I'm getting the error Unable to find 'esbuild'. Install it into your local dev dependencies with 'npm i --save-dev esbuild''. I've already added esbuild to my dev dependencies, and it seems to be installed correctly. My project uses yarn, not npm, but for the sake of testing I tried install it with npm like the error suggested, but that didn't work either.
Has anyone used Firebase Next.js hosting or figured it out since they've released it? The documentation on that page I linked above is... not great.

Make sure that you are using the latest Firebase Tools as per the documentation: "Firebase CLI version 11.14.2 or later".
Run npm install -g firebase-tools to update your version.

Related

Something went wrong installing JavaScript dependencies, check your npm logfile or run npm install again manually [duplicate]

I am using react native and Expo. I am unable to build new app because after I use expo init appName it shows the following error.
Heres the full message:
📦 Using npm to install packages. You can pass --yarn to use Yarn instead.
√ Downloaded and extracted project files.
× Something when wrong installing JavaScript dependencies. Check your npm logs. Continuing to initialize the app.
✅ Your project is ready!
To run your project, navigate to the directory and run one of the following npm commands.
- cd Scanner
- npm start # you can open iOS, Android, or web from here, or run them directly with the commands below.
- npm run android
- npm run ios # requires an iOS device or macOS for access to an iOS simulator
- npm run web
I tried multiple times to create a blank project, also tried npm install to install failed/not downloaded libraries and continue after failure but it showed another error:
npm ERR! code Z_BUF_ERROR
npm ERR! errno -5
npm ERR! zlib: unexpected end of file
also tried npm cache verify that showed cache is ok Content verified: 3562 (252580364 bytes).
So, How can I solve this issue?
Problems related to npm installation are very common If you do any mistake in early installation, but is avoided. Learn more about npm tree.
Steps worked for me are :
npm cache clean --force
npm cache verify
npm -g uninstall expo-cli --save
npm install expo-cli --global
expo init app-name
cd app-name
npm start
Always run as administrator if working on Windows and in root directory.
The solutions above didn't work for me but if you use 'npm install' in the directory of the app you get a clue that you shuold try 'npm install --force'
err message
You should have all these files folders and files at the start of the project otherwise not all the dependencies have been installed which is why we were getting the problem.folder structure
After you have added --force to npm install you have all the dependencies installed. Now you can run the app with npm start.
Unfortunately, all the solutions described above didn't work on my machine...
Here is my latest solution for this problem...
This worked 100% on my machine...
Use npm i -g expo-cli
This will automatically add the required packages and also remove the unnecessary ones.
Yes, surely, you don't need to uninstall and re-install it again.
Just follow my steps.
And, you can create your expo project using expo init.
I hope my solution will help you out from this annoying problem....
I just did npm install and it worked for me, but I had do that every time I create a new expo project.
I also encountered this problem, and finally found that it was the problem of react native cli,I installed the latest version of react native cli,Expo is back to normal
This Error is regarding to the git account. expos need a git account to setup react native project
If you are using windows you need to install git in your local PC
after that open your Terminal and type this command
git config --global user.name "your_username"
git config --global user.email "your_email_address#example.com"
after that clone any github project to your local computer. it will ask to login to Github
after all these steps try expo init <projectname>
The simple way to settle that error is by using "expo-cli init app-name" instead of "expo init app-name".
I tried and worked perfectly for me. Hope it will help you guys.
i have faced a similar problem and running yarn set version 1.22.1 fix it
Run the Command Prompt as an administrator. And run the following command:
npx create-expo-app AwesomeProject

Firebase modular (v9) incompatible with Expo

I'm using Expo v42.0.1 and trying to install Firebase v9.0.2 and am unable to do so.
Issue
From running expo install firebase, firebase version 8.2.3 is installed. When changing the package.json to use firebase version 9.0.2, I get an error when running the app:
"firebase" is added as a dependency in your project's package.json but it doesn't seem to be installed. Please run "yarn" or "npm install" to fix this issue.
What I've tried
Running yarn / npm install
Running expo install firebase#9.0.2 (which ends up just downloading 8.2.3)
Has anyone seen this before or know why it is happening? I believe it is because Expo v42 is not yet compatible with the modular version of firebase (v9).
You are correct.
Has anyone seen this before or know why it is happening? I believe it is because Expo v42 is not yet compatible with the modular version of firebase (v9).
But you can make it work with using it like this in you package.json:
"#firebase": "^9.0.2",
Discussion about this: "firebase" is added as a dependency in your project's package.json but it doesn't seem to be installed
I have used this solution in 2 projects. 1 works perfectly but in another I faced issued where version firebase#9.0.0-beta.7 works perfectly but in version firebase#9.0.2 everything but Firestore works
More about it here: Expo + firebase#9.0.1/9.0.0: #firebase/firestore:, Firestore (9.0.0): Could not reach Cloud Firestore backend

Firebase Deployment Error "Error: Functions did not deploy properly."

I have deployed Firebase functions in the past many times. For some reasons, recently (around 2-3 days) I am frequently getting error while deployment. I am using windows to release the code. When I tried with setting up the same project in my Linux system and Mac system the deployment works correctly. What may be the issue for the release from Windows environment.
The following is the issues getting while deployment.
! functions[payment(us-central1)]: Deployment error.
Function failed on loading user code. This is likely due to a bug in the user code. Error message: Error: please examine your function logs to see the error cause: https://cloud.google.com/functions/docs/monitoring/logging#viewing_logs. Additional troubleshooting documentation can be found at https://cloud.google.com/functions/docs/troubleshooting#logging. Please visit https://cloud.google.com/functions/docs/troubleshooting for in-depth troubleshooting documentation.
Functions deploy had errors with the following functions:
admin
cancellation
cost
createStripeCharge
customer
driver
driverLiveTracking
generalSettings
notification
order
payment
To try redeploying those functions, run:
firebase deploy --only "functions:admin,functions:cancellation,functions:cost,functions:createStripeCharge,functions:customer,functions:driver,functions:driverLiveTracking,functions:generalSettings,functions:notification,functions:order,functions:payment"
To continue deploying other features (such as database), run:
firebase deploy --except functions
Error: Functions did not deploy properly.
Following is the deployment command I am using for
"echo Deploying Functions && npm run lint && npm run build && firebase deploy --only functions"
Please share your knowledge over the issue.
Thanks.
I have resolved this issue. On building, I found that the node modules and lib functions are not replacing correctly with the new build. I have done a name changing previously and that are not reflecting in the new build.
Steps followed:
Removed node modules and lib files
Npm install
Npm run serve
And a new build is worked fine as well. I got the same issue using Jenkins build also. I just manually removed the same in server also.
You can find the issue by examining the actual logs. view them using this command
firebase functions:log
The specific issue will be visible there. I sometimes had error as simple as a missing packages in package.json

Codeship + Firebase functions:config:set = 404 method not found

Hi wonderful people of stackoverflow!
Background
I have an Angular 9 application and CI set up with Codeship. This has been running fine until about two weeks ago when suddenly it stopped working after I upgraded from Angular 7.
Set up commands:
nvm ls
nvm install v10.15.1
nvm use v10.15.1
gem install rb-inotify -v 0.9.10
gem install sass
npm install -g firebase-tools#6.12.0
npm i firebase-functions#3.3.0
yes | npm install -g #angular/cli#9.1.12
npm i
cd functions
nvm use v10.15.1
npm i
cd ..
Which runs as expected. I have checked the versions in the CI environment with npm outdated, which show me that the correct versions are being installed the same as local:
Deploy script:
firebase use default
firebase functions:config:set test="test" --token "$FIREBASE_TOKEN"
firebase deploy --token "$FIREBASE_TOKEN"
Error:
firebase use default is successful, but firebase functions:config:set test="test" --token "$FIREBASE_TOKEN" now returns:
Error: HTTP Error: 404, Method not found.
Notes:
I've reset up the $FIREBASE_TOKEN with the new cli and can confirm that this probably isn't the issue, because when the token is incorrect (I removed the last character from the TOKEN), it throws a different error stating this.
I can also confirm that the same script run locally works and deploys just fine - so while I can get around the problem this way, it isn't an ideal or long term solution.
Any ideas or help would be genuinely appreciated as I'm somewhat lost as to what to do next?
This seems to be related with firebase-tools version. When I installed the same version as you have (6.12.0) I got the same error.
I have tried on new version (I have 8.7.0) and it is working fine with one more remark. When I tried exactly the same command as you have error:
Error: Invalid argument, each config value must have a 2-part key (e.g. foo.bar).
So working command will be like this:
firebase functions:config:set test.test="test"
If you need old version of firebase-tools I tested few other versions and it seems that this is working since version 7.1.0.
For anyone else having this issue - I never managed to solved this sorry. However I migrated my CI over to use GitHub Actions easily and it all works without any issue.

Deploy a SSR Nuxt 2 application on firebase

I have some troubles deploying a Nuxt 2.4 application on Firebase.
I tried these 2 tutorials but they seem outdated:
https://www.youtube.com/watch?v=ZYUWsjUxxUQ
https://github.com/davidroyer/nuxt2-ssr-firebase
With the first tutorial, I could make my app working on local (after few hours and with a lot of modifications for babel integration) but I never could serve or deploy it. I thought the tutorial was old and manipulations can't be exactly done like the guy did.
With the second tutorial, I cloned the repository to try to deploy the example. I had to change 2 things : install Node 8 instead of Node 10 and upgrading firebase-admin to the last version in prod/server dir. Here is what I got:
npm run setup is ok
npm run dev is ok and the project works fine
npm run build is ok
npm run serve fails.
First I got this error :
The Cloud Functions emulator requires the module "firebase-admin" to be version >7.0.0 so your version is too old. You can probably fix this by running "npm install firebase-admin#latest" in your functions directory.
Indeed, the version configured in package.json is the 5.13. I did the update from the prod/server dir, and I get the 8.0.0.
And then I got a different error about gRPC :
Error: Failed to load gRPC binary module because it was not installed for the current system
Expected directory: node-v57-darwin-x64-unknown
Found: [node-v64-darwin-x64-unknown]
This problem can often be fixed by running "npm rebuild" on the current system
I tried npm rebuild as mentionned, without success.
npm run deploy fails.
I get this trace:
i deploying functions, hosting
i functions: ensuring necessary APIs are enabled...
✔ functions: all necessary APIs are enabled
i functions: preparing prod/server directory for uploading...
Error: Error parsing triggers: Cannot find module 'acorn'
Try running "npm install" in your functions directory before deploying.
Of course, I tried the npm install from prod/server dir, but nothing changed.
Is there somewhere i can find a tutorial that can help me deploy my SSR app to firebase ? Thanks in avdance !
EDIT 1 :
After a few modifications on my package.json
upgrading firebase-functions and express to the latest versions
downgrading firebase-admin to the 7.0.0 version
adding acorn
I can serve and deploy but I get a "504 gateway time-out" webpage when I call the URL....
Have you tried to run npm install grpc inside functions folder?

Resources