我正在关注the Cloud Functions tutorial以了解如何使用 Firebase 函数。一切都很顺利,直到 the stage I needed to deploy to the cloud - 由于某种原因,我遇到了语法异常!看来异常是由 lambda 函数引起的:
$ firebase deploy --only functions === Deploying to 'my-project-87547'... i deploying functions Running command: npm --prefix "$RESOURCE_DIR" run lint > functions@ lint E:\Users\Emmet\Documents\firebase_tutorial\functions > eslint . E:\Users\Emmet\Documents\firebase_tutorial\functions\index.js 10:65 error Parsing error: Unexpected token => ✖ 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\Emmet\AppData\Roaming\npm-cache\_logs\2021-03-31T16_31_27_784Z-debug.log events.js:292 throw er; // Unhandled 'error' event ^ Error: spawn npm --prefix "%RESOURCE_DIR%" run lint ENOENT at notFoundError (C:\Users\Emmet\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:6:26) at verifyENOENT (C:\Users\Emmet\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\Emmet\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\Emmet\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 provided in the tutorial itself ,并且它在 Firebase 本地模拟器套件中也按预期成功通过。
作为引用,我正在 Windows 10 PC 上的 Git Bash 终端(使用管理员)运行所有命令。 我的 npm 版本是 6.14.11,NodeJS 版本是 v14.16.0。
我知道其他人也遇到过类似的问题,但我还没有看到有人通过教程脚本本身解决这个问题。提前致谢!
最佳答案
我也有过类似的经历。最终对我有用的是改变
"lint": "eslint .",
到 "lint": "eslint",
在 package.json
内。
我怀疑这是由于在 Windows 计算机上运行该项目所致。
关于node.js - 尝试部署 Firebase Functions 教程时出现语法解析错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66891873/