firebase 部署失败

如何解决firebase 部署失败

嗨,到目前为止,我对命令没有任何问题。我已经为此尝试了几种不同的解决方案,例如清除缓存和 firebase 函数 cmd。但我不断收到此错误。我也阅读了一些资源,但都没有奏效。大家有什么建议吗?

  1:7  error  'functions' is assigned a value but never used  no-unused-vars

✖ 1 problem (1 error,0 warnings)

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! functions@ lint: `eslint .`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the functions@ lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Owner\AppData\Roaming\npm-cache\_logs\2021-01-19T04_28_58_025Z-debug.log
events.js:292
      throw er; // Unhandled 'error' event
      ^

Error: spawn npm --prefix "%RESOURCE_DIR%" run lint ENOENT
    at notFoundError (C:\Users\Owner\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:6:26)
    at verifyENOENT (C:\Users\Owner\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:40:16)
    at ChildProcess.cp.emit (C:\Users\Owner\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:27:25)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
Emitted 'error' event on ChildProcess instance at:
    at ChildProcess.cp.emit (C:\Users\Owner\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:30:37)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12) {
  code: 'ENOENT',errno: 'ENOENT',syscall: 'spawn npm --prefix "%RESOURCE_DIR%" run lint',path: 'npm --prefix "%RESOURCE_DIR%" run lint',spawnargs: []
}

Error: functions predeploy error: Command terminated with non-zero exit code1

index.js 函数

const functions = require("firebase-functions");

// // Create and Deploy Your First Cloud Functions
// // https://firebase.google.com/docs/functions/write-firebase-functions
//
// exports.helloWorld = functions.https.onRequest((request,response) => {
//   functions.logger.info("Hello logs!",{structuredData: true});
//   response.send("Hello from Firebase!");
// });

Package.json

{
  "name": "functions","description": "Cloud Functions for Firebase","scripts": {
    "lint": "eslint .","serve": "firebase emulators:start --only functions","shell": "firebase functions:shell","start": "npm run shell","deploy": "firebase deploy --only functions","logs": "firebase functions:log"
  },"engines": {
    "node": "12"
  },"main": "index.js","dependencies": {
    "firebase-admin": "^9.2.0","firebase-functions": "^3.11.0"
  },"devDependencies": {
    "eslint": "^7.6.0","eslint-config-google": "^0.14.0","firebase-functions-test": "^0.2.0"
  },"private": true
}

调试日志

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   'C:\\Program Files\\nodejs\\node.exe',1 verbose cli   'C:\\Users\\Owner\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',1 verbose cli   '--prefix',1 verbose cli   'C:\\Users\\Owner\\Desktop\\amazon-react\\functions',1 verbose cli   'run',1 verbose cli   'lint'
1 verbose cli ]
2 info using npm@6.14.11
3 info using node@v14.15.3
4 verbose run-script [ 'prelint','lint','postlint' ]
5 info lifecycle functions@~prelint: functions@
6 info lifecycle functions@~lint: functions@
7 verbose lifecycle functions@~lint: unsafe-perm in lifecycle true
8 verbose lifecycle functions@~lint: PATH: C:\Users\Owner\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\Owner\Desktop\amazon-react\functions\node_modules\.bin;C:\Python39\Scripts\;C:\Python39\;C:\Program Files\Java\jdk1.8.0_261\bin;JAVA_HOME\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files (x86)\Common Files\Acronis\VirtualFile\;C:\Program Files (x86)\Common Files\Acronis\VirtualFile64\;C:\Program Files (x86)\Common Files\Acronis\FileProtector\;C:\Program Files (x86)\Common Files\Acronis\FileProtector64\;C:\Program Files (x86)\Common Files\Acronis\SnapAPI\;C:\Program Files (x86)\Brackets\command;C:\Program Files\dotnet\;C:\Program Files (x86)\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files\nodejs\;C:\ProgramData\chocolatey\bin;C:\Program Files\Git\cmd;";C:\mongodb";C:\Program Files\MySQL\MySQL Shell 8.0\bin\;C:\Users\Owner\AppData\Local\Microsoft\WindowsApps;C:\Users\Owner\AppData\Local\atom\bin;C:\Users\Owner\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\Owner\AppData\Local\Microsoft\WindowsApps;C:\Users\Owner\AppData\Roaming\npm;C:\Program Files\MongoDB\Server\4.4\bin;
9 verbose lifecycle functions@~lint: CWD: C:\Users\Owner\Desktop\amazon-react\functions
10 silly lifecycle functions@~lint: Args: [ '/d /s /c','eslint .' ]
11 silly lifecycle functions@~lint: Returned: code: 1  signal: null
12 info lifecycle functions@~lint: Failed to exec lint script
13 verbose stack Error: functions@ lint: `eslint .`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (C:\Users\Owner\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:315:20)
13 verbose stack     at ChildProcess.<anonymous> (C:\Users\Owner\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:315:20)
13 verbose stack     at maybeClose (internal/child_process.js:1048:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
14 verbose pkgid functions@
15 verbose cwd C:\Users\Owner\Desktop\amazon-react
16 verbose Windows_NT 10.0.19041
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Owner\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "--prefix" "C:\\Users\\Owner\\Desktop\\amazon-react\\functions" "run" "lint"
18 verbose node v14.15.3
19 verbose npm  v6.14.11
20 error code ELIFECYCLE
21 error errno 1
22 error functions@ lint: `eslint .`
22 error Exit status 1
23 error Failed at the functions@ lint script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1,true ]

安装

C:\Users\Owner\Desktop\amazon-react>npm install npm -g
C:\Users\Owner\AppData\Roaming\npm\npm -> C:\Users\Owner\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js
C:\Users\Owner\AppData\Roaming\npm\npx -> C:\Users\Owner\AppData\Roaming\npm\node_modules\npm\bin\npx-cli.js
+ npm@6.14.11
added 435 packages from 889 contributors in 17.675s

C:\Users\Owner\Desktop\amazon-react>firebase init functions

     ######## #### ########  ######## ########     ###     ######  ########
     ##        ##  ##     ## ##       ##     ##  ##   ##  ##       ##
     ######    ##  ########  ######   ########  #########  ######  ######
     ##        ##  ##    ##  ##       ##     ## ##     ##       ## ##
     ##       #### ##     ## ######## ########  ##     ##  ######  ########

You're about to initialize a Firebase project in this directory:

  C:\Users\Owner\Desktop\amazon-react

Before we get started,keep in mind:

  * You are initializing in an existing Firebase project directory

? Are you ready to proceed? Yes

=== Project Setup

First,let's associate this project directory with a Firebase project.
You can create multiple project aliases by running firebase use --add,but for now we'll just set up a default project.

i  .firebaserc already has a default project,using fir-a38d0.

=== Functions Setup

A functions directory will be created in your project with a Node.js
package pre-configured. Functions can be deployed with firebase deploy.

? What language would you like to use to write Cloud Functions? JavaScript
? Do you want to use ESLint to catch probable bugs and enforce style? Yes
? File functions/package.json already exists. Overwrite? Yes
+  Wrote functions/package.json
? File functions/.eslintrc.js already exists. Overwrite? (y/N) ? File functions/index.js alre? File functions/.eslintrc.js already exists. Overwrite? Yes
? File functions/index.js already exists. Overwrite? Yes
+  Wrote functions/.eslintrc.js
+  Wrote functions/index.js
? File functions/.gitignore already exists. Overwrite? Yes
+  Wrote functions/.gitignore
? Do you want to install dependencies with npm now? Yes
audited 300 packages in 1.354s

20 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities


i  Writing configuration info to firebase.json...
i  Writing project information to .firebaserc...

+  Firebase initialization complete!

C:\Users\Owner\Desktop\amazon-react>firebase deploy

=== Deploying to 'fir-a38d0'...

i  deploying database,storage,firestore,functions,hosting,remoteconfig
Running command: npm --prefix "$RESOURCE_DIR" run lint

> functions@ lint C:\Users\Owner\Desktop\amazon-react\functions
> eslint .


C:\Users\Owner\Desktop\amazon-react\functions\index.js

解决方法

 1:7  error  'functions' is assigned a value but never used  no-unused-vars

这与您的 eslint 设置有关。如果您分配了一个值,但没有使用它,您的 eslint 首选项设置为抛出错误。

要解决此问题,您可以:

-使用 functions 变量

-更改您的 eslint 首选项以显示警告而不是错误,或禁用 eslint。

eslint 是 Firebase 附带的一个工具,它在部署之前检查您的代码是否有错误,它对于在部署之前捕获内容非常有用。我个人将未使用的变量作为警告而不是错误,所以它仍然会部署。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 &lt;select id=&quot;xxx&quot;&gt; SELECT di.id, di.name, di.work_type, di.updated... &lt;where&gt; &lt;if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 &lt;property name=&quot;dynamic.classpath&quot; value=&quot;tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-