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:UsersOwnerAppDataRoamingnpm-cache_logs2021-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:UsersOwnerAppDataRoamingnpmnode_modulesfirebase-toolsnode_modulescross-envnode_modulescross-spawnlibenoent.js:6:26)
at verifyENOENT (C:UsersOwnerAppDataRoamingnpmnode_modulesfirebase-toolsnode_modulescross-envnode_modulescross-spawnlibenoent.js:40:16)
at ChildProcess.cp.emit (C:UsersOwnerAppDataRoamingnpmnode_modulesfirebase-toolsnode_modulescross-envnode_modulescross-spawnlibenoent.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:UsersOwnerAppDataRoamingnpmnode_modulesfirebase-toolsnode_modulescross-envnode_modulescross-spawnlibenoent.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
}

debug.log

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:UsersOwnerAppDataRoamingnpmnode_modulesnpmnode_modulesnpm-lifecyclenode-gyp-bin;C:UsersOwnerDesktopamazon-reactfunctionsnode_modules.bin;C:Python39Scripts;C:Python39;C:Program FilesJavajdk1.8.0_261bin;JAVA_HOMEbin;C:Program Files (x86)Common FilesOracleJavajavapath;C:WINDOWSsystem32;C:WINDOWS;C:WINDOWSSystem32Wbem;C:WINDOWSSystem32WindowsPowerShellv1.0;C:WINDOWSSystem32OpenSSH;C:Program Files (x86)Common FilesAcronisVirtualFile;C:Program Files (x86)Common FilesAcronisVirtualFile64;C:Program Files (x86)Common FilesAcronisFileProtector;C:Program Files (x86)Common FilesAcronisFileProtector64;C:Program Files (x86)Common FilesAcronisSnapAPI;C:Program Files (x86)Bracketscommand;C:Program Filesdotnet;C:Program Files (x86)dotnet;C:Program FilesMicrosoft SQL Server130ToolsBinn;C:Program FilesMicrosoft SQL ServerClient SDKODBC170ToolsBinn;C:Program Filesnodejs;C:ProgramDatachocolateybin;C:Program FilesGitcmd;";C:mongodb";C:Program FilesMySQLMySQL Shell 8.0bin;C:UsersOwnerAppDataLocalMicrosoftWindowsApps;C:UsersOwnerAppDataLocalatombin;C:UsersOwnerAppDataLocalProgramsMicrosoft VS Codebin;C:UsersOwnerAppDataLocalMicrosoftWindowsApps;C:UsersOwnerAppDataRoamingnpm;C:Program FilesMongoDBServer4.4bin;
9 verbose lifecycle functions@~lint: CWD: C:UsersOwnerDesktopamazon-reactfunctions
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:UsersOwnerAppDataRoamingnpmnode_modulesnpmnode_modulesnpm-lifecycleindex.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:315:20)
13 verbose stack     at ChildProcess.<anonymous> (C:UsersOwnerAppDataRoamingnpmnode_modulesnpmnode_modulesnpm-lifecyclelibspawn.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:UsersOwnerDesktopamazon-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:UsersOwnerDesktopamazon-react>npm install npm -g
C:UsersOwnerAppDataRoamingnpmnpm -> C:UsersOwnerAppDataRoamingnpmnode_modulesnpmbinnpm-cli.js
C:UsersOwnerAppDataRoamingnpmnpx -> C:UsersOwnerAppDataRoamingnpmnode_modulesnpmbinnpx-cli.js
+ npm@6.14.11
added 435 packages from 889 contributors in 17.675s
C:UsersOwnerDesktopamazon-react>firebase init functions
######## #### ########  ######## ########     ###     ######  ########
##        ##  ##     ## ##       ##     ##  ##   ##  ##       ##
######    ##  ########  ######   ########  #########  ######  ######
##        ##  ##    ##  ##       ##     ## ##     ##       ## ##
##       #### ##     ## ######## ########  ##     ##  ######  ########
You're about to initialize a Firebase project in this directory:
C:UsersOwnerDesktopamazon-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:UsersOwnerDesktopamazon-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:UsersOwnerDesktopamazon-reactfunctions
> eslint .

C:UsersOwnerDesktopamazon-reactfunctionsindex.js
1:7  error  'functions' is assigned a value but never used  no-unused-vars

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

要解决这个问题,可以:

-使用functions变量

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

eslint是Firebase自带的一个工具,它会在部署前检查你的代码是否有错误,它对于在部署前捕获错误非常有用。就我个人而言,我将未使用的变量作为警告而不是错误,因此它仍然会部署。

最新更新