当我在我的React应用中启动Firebase时, 经过一些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部署时,我无法做到这一点。相反,我在命令行中遇到了此错误。
Error: HTTP Error: 404, Method not found.
现在,我无法解决此错误。 如果您有任何想法,请帮助我。 谢谢您的阅读!
06/09/2020添加了我的firebase.json并做出了响应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
答案 0 :(得分:1)
首先更新firebase-tools:
Function<Integer, Consumer<Integer>> f3 = n -> x -> {
System.out.println(x * factorial.apply(n));
};
Consumer<Integer> c = f3.apply(5);
c.accept(1); // 120
c.accept(2); // 240
c.accept(3); // 360
c.accept(4); // 480
看到您的屏幕截图后,在部署该功能时我能够看到错误。
尝试在npm install -g firebase-tools
文件中将$ RESOURCE_DIR替换为%RESOURCE_DIR%。
多平台解决方案
Linux
firebase.json
PowerShell
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint"
]
Cmd.exe
"predeploy": [
"npm --prefix $Env:RESOURCE_DIR run lint"
]
以下Github Issue中讨论了前面的内容。请看看。