node.js - 尝试部署 Firebase Functions 教程时出现语法解析错误

标签 node.js firebase npm

我正在关注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 计算机上运行该项目所致。

归功于此回复:https://stackoverflow.com/a/68423649/15719518

关于node.js - 尝试部署 Firebase Functions 教程时出现语法解析错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66891873/

相关文章:

npm - 找不到本地 gulp(尝试运行 : npm install gulp)

javascript - mocha 中的“it”无法使用 await 运行

node.js - 通过 Node.Js 生成的管道 Amazon S3 下载流导致下载不完整

php - GuzzleHttp 不显示来自 Node.js 服务器的响应

javascript - 使用 Firebase FCM 响应 native

firebase - 为 Firebase 的 Cloud Functions 设置超时不会保留在控制台中;这是一个错误吗?

node.js - 无法使用 node npm 安装任何软件包

javascript - Angular 注销不会清除本地存储

java - 安卓 : Firebase dynamic link always goes to playstore URL even if the app is installed

node.js - Node 错误找不到已安装的模块