【发布时间】:2017-06-29 19:25:18
【问题描述】:
第一次在这里部署 GAE 应用程序,我正在尝试遵循本教程:https://firebase.googleblog.com/2016/08/sending-notifications-between-android.html(请参阅节点代码部分)。
我跑了
npm install firebase-admin --save
npm install request --save
在我的机器上,package.json 在这里,但是当我使用gcloud app deploy 时,我在浏览器上打开应用程序时得到这些日志:
2017-02-10 09:35:02 default[20170210t103151] module.js:471
2017-02-10 09:35:02 default[20170210t103151] throw err;
2017-02-10 09:35:02 default[20170210t103151] ^
2017-02-10 09:35:02 default[20170210t103151]
2017-02-10 09:35:02 default[20170210t103151] Error: Cannot find module 'firebase-admin'
2017-02-10 09:35:02 default[20170210t103151] at Function.Module._resolveFilename (module.js:469:15)
2017-02-10 09:35:02 default[20170210t103151] at Function.Module._load (module.js:417:25)
2017-02-10 09:35:02 default[20170210t103151] at Module.require (module.js:497:17)
2017-02-10 09:35:02 default[20170210t103151] at require (internal/module.js:20:19)
2017-02-10 09:35:02 default[20170210t103151] at Object.<anonymous> (/app/server.js:1:78)
2017-02-10 09:35:02 default[20170210t103151] at Module._compile (module.js:570:32)
2017-02-10 09:35:02 default[20170210t103151] at Object.Module._extensions..js (module.js:579:10)
2017-02-10 09:35:02 default[20170210t103151] at Module.load (module.js:487:32)
2017-02-10 09:35:02 default[20170210t103151] at tryModuleLoad (module.js:446:12)
2017-02-10 09:35:02 default[20170210t103151] at Function.Module._load (module.js:438:3)
2017-02-10 09:35:07 default[20170210t103151] module.js:471
2017-02-10 09:35:07 default[20170210t103151] throw err;
2017-02-10 09:35:07 default[20170210t103151] ^
2017-02-10 09:35:07 default[20170210t103151]
2017-02-10 09:35:07 default[20170210t103151] Error: Cannot find module 'firebase-admin'
2017-02-10 09:35:07 default[20170210t103151] at Function.Module._resolveFilename (module.js:469:15)
2017-02-10 09:35:07 default[20170210t103151] at Function.Module._load (module.js:417:25)
2017-02-10 09:35:07 default[20170210t103151] at Module.require (module.js:497:17)
2017-02-10 09:35:07 default[20170210t103151] at require (internal/module.js:20:19)
2017-02-10 09:35:07 default[20170210t103151] at Object.<anonymous> (/app/server.js:1:78)
2017-02-10 09:35:07 default[20170210t103151] at Module._compile (module.js:570:32)
2017-02-10 09:35:07 default[20170210t103151] at Object.Module._extensions..js (module.js:579:10)
2017-02-10 09:35:07 default[20170210t103151] at Module.load (module.js:487:32)
2017-02-10 09:35:07 default[20170210t103151] at tryModuleLoad (module.js:446:12)
2017-02-10 09:35:07 default[20170210t103151] at Function.Module._load (module.js:438:3)
2017-02-10 09:43:58 default[20170210t104151] module.js:471
2017-02-10 09:43:58 default[20170210t104151] throw err;
2017-02-10 09:43:58 default[20170210t104151] ^
2017-02-10 09:43:58 default[20170210t104151]
2017-02-10 09:43:58 default[20170210t104151] Error: Cannot find module 'serviceAccountKey.json'
2017-02-10 09:43:58 default[20170210t104151] at Function.Module._resolveFilename (module.js:469:15)
2017-02-10 09:43:58 default[20170210t104151] at Function.Module._load (module.js:417:25)
2017-02-10 09:43:58 default[20170210t104151] at Module.require (module.js:497:17)
2017-02-10 09:43:58 default[20170210t104151] at require (internal/module.js:20:19)
2017-02-10 09:43:58 default[20170210t104151] at Object.<anonymous> (/app/server.js:7:22)
2017-02-10 09:43:58 default[20170210t104151] at Module._compile (module.js:570:32)
2017-02-10 09:43:58 default[20170210t104151] at Object.Module._extensions..js (module.js:579:10)
2017-02-10 09:43:58 default[20170210t104151] at Module.load (module.js:487:32)
2017-02-10 09:43:58 default[20170210t104151] at tryModuleLoad (module.js:446:12)
2017-02-10 09:43:58 default[20170210t104151] at Function.Module._load (module.js:438:3)
2017-02-10 09:44:10 default[20170210t104151] module.js:471
2017-02-10 09:44:10 default[20170210t104151] throw err;
2017-02-10 09:44:10 default[20170210t104151] ^
2017-02-10 09:44:10 default[20170210t104151]
2017-02-10 09:44:10 default[20170210t104151] Error: Cannot find module 'serviceAccountKey.json'
2017-02-10 09:44:10 default[20170210t104151] at Function.Module._resolveFilename (module.js:469:15)
2017-02-10 09:44:10 default[20170210t104151] at Function.Module._load (module.js:417:25)
2017-02-10 09:44:10 default[20170210t104151] at Module.require (module.js:497:17)
2017-02-10 09:44:10 default[20170210t104151] at require (internal/module.js:20:19)
2017-02-10 09:44:10 default[20170210t104151] at Object.<anonymous> (/app/server.js:7:22)
2017-02-10 09:44:10 default[20170210t104151] at Module._compile (module.js:570:32)
2017-02-10 09:44:10 default[20170210t104151] at Object.Module._extensions..js (module.js:579:10)
2017-02-10 09:44:10 default[20170210t104151] at Module.load (module.js:487:32)
2017-02-10 09:44:10 default[20170210t104151] at tryModuleLoad (module.js:446:12)
2017-02-10 09:44:10 default[20170210t104151] at Function.Module._load (module.js:438:3)
2017-02-10 16:20:02 default[20170210t124920] Error: Credential implementation provided to initializeApp() via the "credential" property failed to fetch a valid Google OAuth2 access token with the following error: "connect ETIMEDOUT 74.125.202.84:443".
2017-02-10 16:20:02 default[20170210t124920] at /app/node_modules/firebase-admin/lib/firebase-app.js:74:23
2017-02-10 16:20:02 default[20170210t124920] at process._tickCallback (internal/process/next_tick.js:103:7)
我该如何解决这个问题??
【问题讨论】:
-
遇到了类似的问题,也有“找不到模块'serviceAccountKey.json'。我感觉这与firebase-admin模块有关。
-
脚本在本地工作吗?是否仅在您部署到 GAE 时才会失败?
-
我不确定我应该如何在本地测试它...不是节点专家(还),你能指导我如何做吗?
-
有人吗?我想解决这个问题:)
-
@jacobawenger,或者知道的人......我也有同样的问题。您能否指定如何部署 serviceAccountKey.json 文件?我的应用程序在本地运行,但是当我部署时,我得到了问题中描述的错误。
标签: node.js google-app-engine firebase firebase-admin