我尝试从外部API获取json数据并将其保存到firebase firestore数据库中,当我运行该函数时,我得到以下错误
我的错误日志
火力基地部署
===正在部署到“borsa-app-f6921”...
i部署函数运行命令:npm --前缀“$RESOURCE_DIR”运行lint
> lint
> eslint .
+ functions: Finished running predeploy script.
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...
+ artifactregistry: required API artifactregistry.googleapis.com is enabled
+ functions: required API cloudbuild.googleapis.com is enabled
+ functions: required API cloudfunctions.googleapis.com is enabled
i functions: preparing codebase default for deployment
! functions: package.json indicates an outdated version of firebase-functions.
Please upgrade-using npm install --save firebase-functions@latest in your functions directory.
! functions: Please note that there will be breaking changes when you upgrade.
i functions: preparing functions directory for uploading...
i functions: packaged C:\Users\yusuf\Desktop\bulut-fonksiyonlari\functions
(75.69 KB) for uploading
+ functions: functions folder uploaded successfully
The following functions are found in your project but do not exist in your local source code:
myFunction(us-central1)
If you are renaming a function or changing its region,
it is recommended that you create the new function first before deleting the old one
to prevent event loss. For more info, visit https://firebase.google.
com/docs/functions/manage- functions#modify
? Would you like to proceed with deletion? Selecting no will continue the rest of
the deployments. Yes
i functions: creating Node.js 16 function saveDataToFirestore(us-central1)...
i functions: deleting Node.js 16 function myFunction(us-central1)...
+ functions[myFunction(us-central1)] Successful delete operation.
Build failed: ...lid: lock file's google-p12-pem@3.1.4 does not satisfy google-p12-pem@2.0.5
npm ERR! Missing: node-forge@0.10.0 from lock fi le
npm ERR! Missing: has-tostringtag@1.0.0 from lock file
npm ERR! Invalid: lock file's yallist@4.0.0 does not satisfy yallist@3.1.1
npm ERR! Missing: define-properties@1.1.4 from lock file
npm ERR! Missing: has-property-descriptors@1.0.0 from lock file
npm ERR! Missing: mimic-fn@2.1.0 from lock file
npm ERR! Missing: duplexify@4.1.2 from lock file
npm ERR! Missing: functions-have-names@1.2.3 from lock file
npm ERR! Invalid: lock file's http-proxy-agent@5.0.0 does not satisfy http-proxy-agent@4.0.1
npm ERR! Invalid: lock file's uuid@8.3.2 does not satisfy uuid@7.0.3
npm ERR! Invalid: lock file's @tootallnate/once@2.0.0 does not satisfy @tootallnate/once@1.1.2
npm ERR! Missing: is-bigint@1.0.4 from lock file
npm ERR! Missing: is-boolean-object@1.1.2 from lock file
npm ERR! Missing: is-number-object@1.0.7 from lock file
npm ERR! Missing: is-symbol@1.0.4 from lock file
npm ERR! Missing: has-bigints@1.0.2 from lock file
npm ERR! Missing: is-weakmap@2.0.1 from lock file
npm ERR! Missing: is-weakset@2.0.2 from lock file
npm ERR! Missing: available-typed-arrays@1.0.5 from lock file
npm ERR! Missing: for-each@0.3.3 from lock file
npm ERR! Missing: gopd@1.0.1 from lock file
npm ERR! Missing: is-typed-array@1.1.10 from lock file
npm ERR! Missing: is-callable@1.2.7 from lock file
npm ERR! Missing: p-try@2.2.0 from lock file
npm ERR! Missing: core-util-is@1.0.3 from lock file
npm ERR! Missing: isarray@1.0.0 from lock file
npm ERR! Missing: process-nextick-args@2.0.1 from lock file
npm ERR! Missing: safe-buffer@5.1.2 from lock file
npm ERR! Missing: string_decoder@1.1.1 from lock file
npm ERR! Missing: @firebase/auth-interop-types@0.1.5 from lock file
npm ERR! Missing: @firebase/util@0.3.2 from lock file
npm ERR! Missing: @firebase/component@0.1.19 from lock file
npm ERR! Missing: @firebase/database-types@0.5.2 from lock file
npm ERR! Missing: tslib@1.14.1 from lock file
npm ERR! Missing: @firebase/app-types@0.6.1 from lock file
npm ERR!
npm ERR! Clean install a project
npm ERR!
npm ERR! Usage:
npm ERR! npm ci
npm ERR!
npm ERR! Options:
npm ERR! [-S|--save|--no-save|--save-prod|--save-dev|--save-optional|--save-peer|--save-bundle]
npm ERR! [-E|--save-exact] [-g|--global] [--global-style] [--legacy-bundling]
npm ERR! [--omit <dev|optional|peer> [--omit <dev|optional|peer> ...]]
npm ERR! [--strict-peer-deps] [--no-package-lock] [--foreground-scripts]
npm ERR! [--ignore-scripts] [--no-audit] [--no-bin-links] [--no-fund] [--dry-run]
npm ERR! [-w|--workspace <workspace-name> [-w|--workspace <workspace-name> ...]]
npm ERR! [-ws|--workspaces] [--include-workspace-root] [--install-links]
npm ERR!
npm ERR! aliases: clean-install, ic, install-clean, isntall-clean
npm ERR!
npm ERR! Run "npm help ci" for more info
npm ERR! A complete log of this run can be found in:
npm ERR! /www-data-home/.npm/_logs/2022-12-14T11_02_18_814Z-debug-0.log; Error ID: beaf8772
Functions deploy had errors with the following functions:
saveDataToFirestore(us-central1)
i functions: cleaning up build files...
! functions: Unhandled error cleaning up build images. This could result in a small
monthly bill if not corrected. You can attempt to delete these images
by redeploying or you can delete them manually
at https://console.cloud.google.com/artifacts/docker/borsa-app-f6921/us-central1/gcf-artifacts
Error: There was an error deploying functions
这是我的密码
const functions = require("firebase-functions");
const admin = require("firebase-admin");
const axios = require("axios");
admin.initializeApp();
const db = admin.firestore();
exports.saveDataToFirestore = functions.https.onRequest((request, response) => {
axios.get("https://api.coingecko.com/api/v3/coins/markets? vs_currency=usd&order
=market_cap_desc&per_page=100&page=1&sparkline=true")
.then((res) => {
db.collection("data").add(res.data)
.then(() => {
response.send("successful");
})
.catch((err) => {
response.send("Error " + err);
});
})
.catch((err) => {
response.send("Error REST API: " + err);
});
});
1条答案
按热度按时间tzcvj98z1#
你能把你的节点从16改为14吗?如果可以的话,告诉我。如果14不行的话,把12或者10中的任何一个放上去。因为你使用的是firebase 8,这可能是一个兼容性问题
以下是一个可用的包. json
你可以尝试在这里安装firebase,firebase-admin和firebase-functions的版本,这对我的项目是有效的。我可以部署这些函数。在部署之前执行
npm install
按如下所示更新函数