Firebase functions deploy results in "Error in the build environment" - node.js

When I try to deploy functions with the firebase-tools cli I always receive a Deployment error for every function. The output looks like this:
! functions[import]: Deployment error.
Error in the build environment
I have tried to deploy in different ways:
firebase deploy --only functions
and
firebase deploy --only functions:[function-name]
Both result in a Deployment error. The packaged functions folder gets upload successfully.
Is there any way to update my current functions?

I did as #Jirawatee has suggested but was then having some issues with my node version.
So I changed my version of node to V8 and added the engine key my package.json. then removed my node modules, reinstalled them and tried the deploy again
so:
1.) install updates
npm install firebase-functions#latest firebase-admin#latest --save
npm install -g firebase-tools
2.) change your global node version to 8 I personally use Nodist for Windows to manage my node version
3.) add engine to package.json
"engines": {
"node": "8"
},
4.) remove and reinstall node modules
rm -rf node_modules && npm install
5.) finally, run your firebase build / deploy script

I meet this problem too and I fix it by command lines below.
npm install firebase-functions#latest firebase-admin#latest --save
npm install -g firebase-tools
Hope it will help :)

Related

Using firebase cli when not installed globally

I'm using my work computer while developing a sort of side project. Nothing crazy just learning some new firebase stuff. Anyways, because it is a work computer I can't install modules globally. So when it came to installing firebase-cli I tried using the recommended global command:
npm install -g firebase-tools
That didn't work because I don't have permission due to this being a work computer. So I created a firebase folder just for this project and ran
npm install firebase-tools
In the new folder. Once finished I tried running
firebase -version
But this resulted in
firebase: command not found
I thought this would work since I'm in the directory I created and installed firebase in but it doesn't work. Any help please!
If you want to run any command from a package that was installed in a project, use npm exec from the project folder.
npm exec -- firebase [CLI args]
The version command you were trying to run would go like this (note it's two dashes for the flag)
npm exec -- firebase --version

Why npx create-react-app is showing "the project was bootstrapped with an old unsupported version of tools"?

I recently switched to Ubuntu, whenever I create react app it's giving me this note, and the app it's creating is a class component.
ankit#gram:~/Documents/Development/React/react-project$ npx create-react-app my-app
Creating a new React app in /home/ankit/Documents/Development/React/react-project/my-app.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...
added 987 packages in 39s
22 packages are looking for funding
run `npm fund` for details
Success! Created my-app at /home/ankit/Documents/Development/React/react-project/my-app
Inside that directory, you can run several commands:
npm start
Starts the development server.
npm run build
Bundles the app into static files for production.
npm test
Starts the test runner.
npm run eject
Removes this tool and copies build dependencies, configuration files
and scripts into the app directory. If you do this, you can’t go back!
We suggest that you begin by typing:
cd my-app
npm start
Happy hacking!
Note: the project was bootstrapped with an old unsupported version of tools.
Please update to Node >=14 and npm >=6 to get supported tools in new projects.
my node version: v16.14.0
my npm version:8.3.1
I think this was because npx was not installed in my system, when I created a react app by this command create-react-app the app created was fine. I also installed npx using this command npm install -g npx and created a react app and everything was fine. before this make sure you have installed create-react-app in your system if not then install it by using this command
sudo npm install -g create-react-app
I am a new programmer had this issue not long ago I just solved it.
Use sudo apt install nodejs
It will automatically install version 10 for you which doesn't accept React.
Then you try to install NVM package, use it to update your node to a newer version.
You can check me on GitHub bari racha Wuye
I was having the same problem after I had just installed Ubuntu 22.04.
The fix for me was updating node and npm by following these instructions free code camp update node and npm
Specifically, I followed the instructions under the heading "1. Use NPM to Update Your Node Version", to update node and ignored the 2nd and 3rd headings, then followed the instructions under the last heading to update npm
afterwards I restarted my computer, opened the project directory and ran the command
npm i create-react-app#latest
then I ran
npx create-react-app projectname
and it worked as expected

I want to degrade the serverless version from 2.41.2 to 2.35.0

By mistake I had installed the higher version of serverless on my pc. Now I want to degrade my serverless framework version from v2.41.2 to v2.35.0 due to some project requirements.
What I had tried to do:
I uninstalled the current serverless framework with npm uninstall -g serverless.
Then ran this command npm install -g serverless#2.35.0
But when I ran this command serverless --version it is still showing the version 2.41.2 on my pc.
In addition to being installed globally via NPM, serverless can also be a project dependency. If you're working in a node project, ensure that serverless isn't listed in the package.json file or in the package-lock.json file.
If so, run npm uninstall serverless and then npm install -d serverless#2.35.0, to install the framework in the project at the correct version.

React Native error : 'react-native' is not recognized as an internal or external command, operable program or batch file

I have been using React-Native for a project it's been more than a month, to create the app I uninstalled the react-native-cli and followed what is described in the official docs (https://reactnative.dev/docs/environment-setup). Yesterday, I modified an existing project (from github) and run :
npm install
npx react-native run-android
I had some errors so I updated npm, everything worked fine. I restarted my computer and tried to create a new app using the following command:
npx react-native init Test
This is the error that I get:
I uninstalled Node and installed the newest version (16.0.0) with npm version (7.11.2) and npx version (7.11.2).
Can someone please help me with this?
Uninstalling global packages
use this commond
npm uninstall -g react-native-cli
then restart computer and try create new app
I restarted my computer and tried to create a new app using the following command: npx react-native run-android Test
to create new app in react native use init not run-android
npx react-native init Test
i think you need to install react native cli but first Add npm path to your Environment variables; both system and user then install npm and react-native cli.
and if that does not work,Solution is to install react-native-cli globally You can install it globally by using the below command:
npm install -g react-native-cli

Firebase Server complains that firebase-admin is installed but not seen

I tried running firebase serve on my local machine and gets below warning
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.
What I've tried from previous SO and github
npm install from folder functions
delete node_modules and re-run npm install
run npm install --save firebase-admin
SO and github references but non solved my problem
The Cloud Functions emulator requires the module "firebase-admin" to be installed
Im having trouble while serving or deploying Firebase Hosting Functions
https://github.com/firebase/firebase-tools/issues/1452
PS:
Downgrade to version 6 is not an option.
I'm running node 8 and "firebase-admin": "^8.6.0" as shown from package.json
With the help of Hiranya Jayathilaka comment above I was able to fix this. I upgraded my node from 8.5.x to 8.16.2 and run npm install firebase-tools and everything works fine.

Resources