我关注 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。
我知道其他人也遇到过类似的问题,但我还没有看到有人通过教程脚本本身解决了这个问题。提前致谢!