当我尝试部署我的Firebase云函数时,我会得到以下错误。
期望的行为:成功地部署函数。
错误:
错误:读取函数/Package.json时出错:
函数/lib/index.js不存在,无法部署云函数
完整日志:
名称@name-MacBook函数% firebase部署
===部署到“newtiktok-21570”.
我部署函数运行命令: npm -前缀"$RESOURCE_DIR“运行lint
函数@ lint /Users/name/Desktop/Yoveo/function eslint "src/**/*“
/Users/name/Desktop/Yoveo/functions/src/index.ts
186:67警告“时间戳”已定义,但从未使用。
@typescript-eslint/no未使用-vars 377:86警告'mediaNum‘已定义,但从未使用@typescript-eslint/no-未使用-vars 377:104警告'commentText’已定义,但从未使用@typescript eslint/no-未使用-vars 377:125警告'commentID‘已定义,但从未使用@类型记录-eslint/no-未使用-vars 419:119警告'commentID’已定义,但从未使用。
@typescript-eslint/no- used vars 463:121警告'commentID‘已定义,但从未使用@typescript-eslint/no-unused vars 520:75。
警告'mediaNum‘已定义,但从未使用
@typescript-eslint/no- used vars 732:25警告“扇”是定义的,但从未使用过@typescript-eslint/no-used vars。
✖8问题(0错误,8警告)
运行命令: npm -前缀"$RESOURCE_DIR“运行构建✔函数:完成运行预部署脚本。
错误:读取函数/Package.json时出错:
我的p.json:
{
"name": "functions",
"scripts": {
"lint": "eslint \"src/**/*\"",
"build": "",
"serve": "npm run build && firebase emulators:start --only functions",
"shell": "npm run build && firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"engines": {
"node": "12"
},
"main": "lib/index.js",
"dependencies": {
"firebase-admin": "^9.2.0",
"firebase-functions": "^3.11.0"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^4.8.1",
"@typescript-eslint/parser": "^4.8.1",
"eslint": "^7.14.0",
"eslint-plugin-import": "^2.22.0",
"firebase-functions-test": "^0.2.0",
"typescript": "^3.8.0"
},
"private": true
}发布于 2020-11-25 00:14:41
解决:
我能够通过删除与Firebase函数相关的所有内容来解决这个问题。再次运行:firebase init。在我cd functions运行npm install之后。然后,在修复了以下错误之后,我能够成功地部署:
3:26 error 'express' should be listed in the project's dependencies. Run 'npm i -S express' to add it import/no-extraneous-dependencies发布于 2022-07-02 14:36:36
光盘到函数文件夹中并运行以下命令
npm运行脚本构建
这将创建缺少的lib/index.js文件。
发布于 2021-12-18 08:06:28
firebase在package.json中使用package.json字段作为程序入口点,正确设置它,可能是这样的。
"main": "lib/src/index.js",https://stackoverflow.com/questions/64960780
复制相似问题