【发布时间】:2020-12-24 16:29:32
【问题描述】:
当我在我的 react 应用上初始化 firebase 时, 在我通过一些火力基地询问后,我得到了主题错误。
下面详细介绍。
What language would you like to use to write Cloud Functions? (Use arrow keys)
❯ JavaScript
TypeScript (node:82729) UnhandledPromiseRejectionWarning: Error
at new FirebaseError (/usr/local/lib/node_modules/firebase-tools/lib/error.js:9:18)
at module.exports (/usr/local/lib/node_modules/firebase-tools/lib/responseToError.js:38:12)
at Request._callback (/usr/local/lib/node_modules/firebase-tools/lib/api.js:39:35)
at Request.self.callback (/usr/local/lib/node_modules/firebase-tools/node_modules/request/request.js:185:22)
at Request.emit (events.js:315:20)
at Request.EventEmitter.emit (domain.js:483:12)
at Request.<anonymous> (/usr/local/lib/node_modules/firebase-tools/node_modules/request/request.js:1161:10)
at Request.emit (events.js:315:20)
at Request.EventEmitter.emit (domain.js:483:12)
at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/firebase-tools/node_modules/request/request.js:1083:12)
(node:82729) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:82729) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
我以前创建一些 React 应用程序时没有出现这样的错误。但是,我今天收到了这个错误。我想我会在我的 node.js 上收到这个错误。但我不知道如何修复我的 node.js。
我是 node.js 和 firebase 的初学者。 我应该如何解决这个错误?
我尝试修复在 Internet 上找到的一些解决方案。关注
我确实从 v10.12.3 重新安装了 node.js v12.18.3。此外,我在我的 Mac 上重新安装了 firebase-tools。我试图在 firebase 初始化之前在我的 react 应用程序上重新安装 firebase。
另外,我忽略了这个错误,然后完成了 firebase 的初始化。但是当我执行 firebase deploy 时,我不能这样做。相反,我在命令行上收到了这个错误。
Error: HTTP Error: 404, Method not found.
现在,我无法解决此错误。 如果您有任何想法,请帮助和建议我。 感谢您的阅读!
06/ 09 / 2020 添加了我的 firebase.json 和 react package.json。 这是firebase.json
{
"firestore": {
"rules": "firestore.rules",
"indexes": "firestore.indexes.json"
},
"functions": {
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint"
]
},
"hosting": {
"public": "build",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
这里是 package.json
{
"name": "react-bot",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
"firebase": "^7.19.1",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-scripts": "3.4.3"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
已安装的软件包。
firebase-tools@8.10.0
firebase@7.19.1
node.js v12.18.3
macOS10.15.6
【问题讨论】:
-
你能分享你的代码吗?当必须在处理拒绝的承诺上使用 .catch() 处理未处理的承诺拒绝时,通常会出现该错误。您能否将 firebase-tools 更新到最新版本并运行 firebase login --reauth ?请让我知道它是否有效。
-
另外请分享您的 firebase.json 文件,以防前一个不起作用。
-
@NibrassH 感谢您的回复。一旦我删除了所有项目。 firest ,我确实为 firebase-tools@8.10.0 更新了 firebase-tools。然后我在我的反应应用程序上重新安装了 firebase@7.19.1。我做了firebase登录--reauth。但是,我得到了同样的错误......
-
@NibrassH 另外,我将 firebase.json 和 package.json 放在这里。请检查。如果您发现任何问题,请告诉我,我想解决这个问题。
-
感谢您分享以上所有信息。我在下面添加了一个答案。
标签: node.js firebase firebase-cli