why do I have this error deploying firebase simple function? - node.js

I am new to firebase and trying to deploy a basic function to add users to firestore databse
const functions = require("firebase-functions");
const admin = require('firebase-admin');
admin.initializeApp();
const db = admin.firestore()
exports.newUser = functions.auth.user().onCreate((user) => {
return db
.collection("user")
.doc(user.uid)
.create(JSON.parse(JSON.stringify(user)))
})
I get this error? no idea why it happens
i functions: updating Node.js 16 function newUser(us-central1)...
Build failed: npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: functions#undefined
npm ERR! Found: firebase-admin#undefined
npm ERR! node_modules/firebase-admin
npm ERR! firebase-admin#"^111.5.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer firebase-admin#"^10.0.0 || ^11.0.0" from firebase-functions#4.2.1
npm ERR! node_modules/firebase-functions
npm ERR! firebase-functions#"^4.2.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /www-data-home/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /www-data-home/.npm/_logs/2023-02-19T06_03_09_079Z-debug-0.log; Error ID: b0ba1f57
Functions deploy had errors with the following functions:
newUser(us-central1)
i functions: cleaning up build files...
Error: There was an error deploying functions
did anyone face this before or how do I solve this issue?

Firebase-admin is currently on version 11.5. Your error is stating that it can't find version 115.0. It seems likely your package.json contains:
"firebase-admin": "^115.0"
When it should actually be:
"firebase-admin": "^11.5"
Try running:
npm uninstall firebase-admin & npm install firebase-admin

The firebase installation script seems to have a problem with setting the version correctly. Try initializing a new project, and right when it asks you whether you want to resolve dependencies, you can manually change the package.json located in the subfolder it just initialized for you at your selected path, and replace 115.0 with 11.5. Then type y and it will continue as it should.

Related

How to fix npm Err ERESOLVE peer depandencies for ReactJS for Vercel Hosting deployment

Synopsis
After about a month of working, I could deploy my project. I cloned the folder (just in case) and used Git to upload it to my GitHub Repository. I then logged onto Vercel's Hosting, chose their free hobby pricing (the free one) and connected my Github account to which I uploaded my portfolio. I then pressed 'deploy' and received an error that started with "npm Err code ERESOLVE" please look at the section marked an error. After about 2-3 hours of researching and Stack Overflow looking, I could find an answer.
Context
After completing my month-long project on VS Code, I decided to clone the folder and remove everything inside the directory outside. This means that I originally had my VScode folder and another folder that npx created (Image 1). However, to upload it to Github, I removed it from the following folder created and put it in the main outside folder (See image 2). Then I downloaded Git (checked it using its version) and uploaded my copied folder to a GitHub Repo called portfolio-new (check marked Github repo below). Once I was done, I headed to Vercel, a hosting platform, and decided to host my react project there. Vehicle integration makes it, so they run their npm start on their platform. Therefore I have no control over the deployment after I press 'deploy.' After pressing deploy, I received an error of dependencies (see error below).
Problem
To recap, as mentioned above, the problem is that Vercel is its system, and I cannot control how it does npm start (you will see why that is important). Therefore when it runs, it is an error. It means I must fix the code, not how I run it.
Why not use --force or --legacy-peer-deps
The issue with this is that Vercel's system needs to let me control its commands. Therefore, I cannot use either of these commands to make it force to run. That means the answer that shall be posted must fix the actual error instead of having a temporary go-around. Again to repeat, I CANNOT use these two commands!
[13:28:58.885] Cloning github.com/Abdjsjiski/portfolio-new (Branch: main, Commit: 5f53564)
[13:28:58.889] Skipping build cache since Vercel CLI used --force option
[13:28:59.634] Cloning completed: 748.787ms
[13:29:00.056] Running "vercel build"
[13:29:00.521] Vercel CLI 28.10.0
[13:29:01.088] Installing dependencies...
[13:29:02.759] npm ERR! code ERESOLVE
[13:29:02.775] npm ERR! ERESOLVE could not resolve
[13:29:02.775] npm ERR!
[13:29:02.775] npm ERR! While resolving: react-notifications-menu#1.0.6
[13:29:02.776] npm ERR! Found: react#18.2.0
[13:29:02.776] npm ERR! node_modules/react
[13:29:02.776] npm ERR! react#"^18.2.0" from the root project
[13:29:02.776] npm ERR! peer react#">=16.8.0" from #emotion/react#11.10.5
[13:29:02.776] npm ERR! node_modules/#emotion/react
[13:29:02.776] npm ERR! #emotion/react#"^11.10.5" from the root project
[13:29:02.776] npm ERR! peer #emotion/react#"^11.0.0-rc.0" from #emotion/styled#11.10.5
[13:29:02.776] npm ERR! node_modules/#emotion/styled
[13:29:02.776] npm ERR! #emotion/styled#"^11.10.5" from the root project
[13:29:02.776] npm ERR! 3 more (#mui/material, #mui/styled-engine, #mui/system)
[13:29:02.776] npm ERR! 3 more (#mui/material, #mui/styled-engine, #mui/system)
[13:29:02.776] npm ERR! 41 more (#emotion/styled, ...)
[13:29:02.777] npm ERR!
[13:29:02.777] npm ERR! Could not resolve dependency:
[13:29:02.777] npm ERR! peer react#"^15.0.0 || ^16.0.0" from react-notifications-menu#1.0.6
[13:29:02.777] npm ERR! node_modules/react-notifications-menu
[13:29:02.777] npm ERR! react-notifications-menu#"^1.0.6" from the root project
[13:29:02.777] npm ERR!
[13:29:02.777] npm ERR! Conflicting peer dependency: react#16.14.0
[13:29:02.777] npm ERR! node_modules/react
[13:29:02.777] npm ERR! peer react#"^15.0.0 || ^16.0.0" from react-notifications-menu#1.0.6
[13:29:02.777] npm ERR! node_modules/react-notifications-menu
[13:29:02.777] npm ERR! react-notifications-menu#"^1.0.6" from the root project
[13:29:02.777] npm ERR!
[13:29:02.778] npm ERR! Fix the upstream dependency conflict, or retry
[13:29:02.778] npm ERR! this command with --force, or --legacy-peer-deps
[13:29:02.778] npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
[13:29:02.778] npm ERR!
[13:29:02.778] npm ERR! See /vercel/.npm/eresolve-report.txt for a full report.
[13:29:02.778]
[13:29:02.778] npm ERR! A complete log of this run can be found in:
[13:29:02.778] npm ERR! /vercel/.npm/_logs/2022-12-31T18_29_01_308Z-debug-0.log
[13:29:02.796] Error: Command "npm install" exited with 1
Github Repo
If it isnt obvious by now i am using only pure ReactJS
Before I clone the folder
After the cloned folder and put everything outside
i am aware there are many similar questions to mine but mine has more to do with how to fix the actual problem then the other temporary go arounds + how to deploy it properly instead of leaving it on Vercel
Before posting, I did some research which included the following:
Using the --force or -- legacy-peer-deps command anyway
Removing node modules and package-lock.json and doing the npm install
Removing cache with force
Audit fix -- force and audit fix normal
npm fund
Re-installing / updating ALL my dependencies with force
Updating react scripts
Using -- save and retrying all commands
None of these worked. I updated my GitHub repo to the newest version, redeployed it, and got the same error.
Why does your problem differ from others
It's mostly not related to the code but to the hosting platform therefore the normal answers wont work such as the above given but to fix the problem you need to fix the code itself
Ok, I found an answer after three more hours of searching!!
In Vercel, go to the change command lines and look for npm install or yarn install
Note this is more of a workaround ironic to my question but It sufficed
You can then change the command to npm install --force and it will deploy but I would still be really glad if anyone could fix the actual problem that occured

npm ERESOLVE could not resolve #angular/elements#11.2.14 after trying to update to angular 12

I have a angular 11 application and i wanted to update it to the latest 14, based on the officiel website i had to go update one by one so 11 to 12, 12 to 13 and 13 to 14.
So i created a new branch on git and started [here][1] with ng update #angular/core#12 #angular/cli#12, i had a bunch of dependencies issues after so i rolled back on the master branch, but i still have problems with npm dependencies, everytime i do a npm install i have something like this that i don't understand at all :
npm i
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: #angular/elements#11.2.14
npm ERR! Found: #angular/core#11.0.9
npm ERR! node_modules/#angular/core
npm ERR! #angular/core#"~11.0.9" from the root project
npm ERR! peer #angular/core#"11.0.9" from #angular/animations#11.0.9
npm ERR! node_modules/#angular/animations
npm ERR! #angular/animations#"~11.0.9" from the root project
npm ERR! peer #angular/animations#"^11.0.0 || ^12.0.0-0" from #angular/material#11.0.3
npm ERR! node_modules/#angular/material
npm ERR! #angular/material#"^11.0.3" from the root project
npm ERR! 1 more (#angular/platform-browser)
npm ERR! 13 more (#angular/cdk, #angular/common, #angular/fire, ...)
I tried to do npm install --force and npm install --legacy-peer-deps, but still i can't just do npm install as i'm used to, is there something that breaks angular when doing the ng update.
for the versions that i use i have :
Angular CLI: 11.0.7
Node: 16.15.1
OS: win32 x64
Angular: 11.0.9
npm: 8.11.0
Do you think i need to reinstall angular? I don't get how the project can be broken when i rolled back to the branch before any modification on the project. I feel like the easiest way to update is to create a new project on the version you want and add everything back in it little by little.
if you have any idea on this i'll take it.
Thanks in advance !
[1]: https://update.angular.io/?l=3&v=11.0-12.0

When I run `ng new`, npm has a dependency problem [duplicate]

This question already has answers here:
unable to resolve dependency tree error for creating new angular project
(16 answers)
Closed 1 year ago.
i ran ng new in terminal. I ended up getting an npm error
new folder
run ng new in new folder
set the name and accept defaults (and use SCSS)
watch it create files and error at the end
⠸ Installing packages (npm)...npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: project-name#0.0.0
npm ERR! Found: jasmine-core#3.7.1
npm ERR! node_modules/jasmine-core
npm ERR! dev jasmine-core#"~3.7.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer jasmine-core#">=3.8" from karma-jasmine-html-reporter#1.7.0
npm ERR! node_modules/karma-jasmine-html-reporter
npm ERR! dev karma-jasmine-html-reporter#"^1.5.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /Users/user/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/user/.npm/_logs/2021-07-11T18_12_50_796Z-debug.log
✖ Package install failed, see above.
The Schematic workflow failed. See above.
I had this same issue with a fresh project, etc.
In the generated package.json you should see a line that says "jasmine-core": "~3.7.0" but it seems that other dependencies (I believe karma based on the error output here) require jasmine-core at 3.8.0 or higher. Simply edit the line that says "jasmine-core": "~3.7.0", to be "jasmine-core": "~3.8.0", and then manually run npm install and it should succeed.
You should then be able to run ng serve --open from the same directory and have it run just fine.
I changed "jasmine-core": "~3.7.0", to "jasmine-core": "~3.8.0" in package.json.template, I can create projects with no issues now.
The location may vary, mine is:
/usr/local/lib/node_modules/#angular/cli/node_modules/#schematics/angular/workspace/files/package.json.template
This will fix the problem in new projects

npm install fails (unable to resolve dependency tree)

Trying to reduce any changing variables and using a fresh pull of my code. They are no node-module packages or package-lock.json. I run npm install I get this error:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: undefined#undefined
npm ERR! Found: react-native-screens#2.15.2
npm ERR! node_modules/react-native-screens
npm ERR! react-native-screens#"~2.15.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react-native-screens#"^1.0.0 || ^1.0.0-alpha" from react-navigation-drawer#1.4.0
npm ERR! node_modules/react-navigation-drawer
npm ERR! react-navigation-drawer#"^1.4.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /Users/myname/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/myname/.npm/_logs/2021-05-22T01_16_02_351Z-debug.log
If I do an install via --force or npm install --legacy-peer-deps I get a bunch of files mark as outdated and when I run npm update I get the same error. I have tried clearning the cache of my npm as well with no luck npm cache clean. I don't know why this is happening as there is no node-module folder or anything installed for it to give error under my node_modules/react-native-screens...they are no node_modules folder yet. What is causing this and how can I fix it?
Edit:
I ran npm update -g , then npm audit fix and then I got an error:
code ERESOLVE
ERESOLVE unable to resolve dependency tree
While resolving: Sculp latest app#undefined
Found: react-native-screens#2.15.2
node_modules/react-native-screens
react-native-screens#“~2.15.0” from the root project
so I ran expo install react-native-screens and saw that it couldn't find expo...checked my folder and my node_module folder is missing. Like if it never was there or gotten installed.
edit:
I have tried all the methods listed below and it gives random errors that I can not fix it undefined is not an object (evaluating ‘_core.ThemeColors.light’) and I have googled this and one of the main solutions is delete npm and package-lock.json and reinstall but that brings me back to where I started.
It works for me:
npm install --save --legacy-peer-deps
Try this:
npm config set legacy-peer-deps true
Note: this will set this flag permanently
For one time:
npm install --save --legacy-peer-deps
Try to copy your src folder and package.json file and initialize another react-native (new) and replace the source the src folder and package.json file and reenter npm install.
You can use --force in the command line, but you will problably have to deal with a broken react-native dependency later. Anyway, there are other ways of dealing with this broken dependency.
Try it in the following:
npm add react-native
expo install (your needed module)

Hyperleger Indy - TheOrgBook Module Build Failure due to Node and NPM Issue

I have deployed VON Network and Permitify Modules of Hyperledger Indy SSI VC Demo in MacOS successfully. I am facing issues in TheOrgBook setup. However TheOrgBook Demo is failing even after trying the hot fix suggested in the GitHub Issue #26.
ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/opt/app-root/src/src'
ERROR in Error: Error encountered resolving symbol values statically. Could not resolve localize-router relative to /opt/app-root/src/src/app/app.module.ts., resolving symbol AppModule in /opt/app-root/src/src/app/app.module.ts, resolving symbol AppModule in /opt/app-root/src/src/app/app.module.ts, resolving symbol AppModule in /opt/app-root/src/src/app/app.module.ts
npm ERR! code ELIFECYCLE
npm ERR! Failed at the tob-web#0.0.1 postinstall script 'ng build --prod --base-href ${NG_BASE_HREF:-/} ${NG_BUILD_FLAGS:-} && cp dist/themes/_active/index.html dist/index.html'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the tob-web package,
npm ERR! not with npm itself.
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs tob-web
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls tob-web
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /opt/app-root/src/npm-debug.log
Build failed
Wrong example, try this one link

Resources