[英]google cloud platform: “Can't find module firebase-admin”
I am trying to deploy my node.js server to google cloud platform. 我正在尝试将node.js服务器部署到Google云平台。 It works perfectly when I use it locally (run it with
npm start
of node app.js
). 当我在本地使用它时,它可以完美工作(在
node app.js
npm start
处运行)。
But when I try to deploy it ( gcloud deploy
), it failed, and in the Log: 但是,当我尝试部署它(
gcloud deploy
)时,它失败了,并且在日志中:
Error: Cannot find module 'firebase-admin' at Function.Module._resolveFilename (module.js:469:15) at Function.Module._load (module.js:417:25) at Module.require (module.js:497:17) at require (internal/module.js:20:19) at Object.
错误:在Function.Module._resolveFilename(module.js:469:15)的Module.require(module.js:497:25)的Function.Module._resolveFilename(module.js:469:15)上找不到模块“ firebase-admin” :17)的Object(internal / module.js:20:19)。 (/app/app.js:28:16) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3)
(/app/app.js:28:16)在Module._compile(module.js:570:32)在Object.Module._extensions..js(module.js:579:10)在Module.load(module。 js:487:32)在tryModuleLoad(module.js:446:12)在Function.Module._load(module.js:438:3)
in app.js i use simply: 在app.js中,我简单地使用:
var firebase = require("firebase-admin");
and this is my package.json file: 这是我的package.json文件:
{
"name": "Talk2Me-server",
"version": "1.0.3",
"main: "app.js",
"description": "Talk2Me app server",
"private": true,
"license": "Apache-2.0",
"scripts": {
"start": "node app.js"
},
"repository": {
"type": "git",
"url": "https://github.com/guytsur/Talk2Me.git"
},
"author": "Talk2Me Team,",
"contributors": [
"Guy Tsur<guytsur7@google.com>"
],
"cloud-repo-tools": {
"requiresKeyFile": true,
"requiresProjectId": true
},
"dependencies": {
"express": "~4.15.2",
"request": "^2.81.0",
"firebase-admin": "^4.1.2",
"firebase": "^2.4.2"
},
"devDependencies": {
"@google-cloud/nodejs-repo-tools": "1.4.16",
"ava": "~0.21.0",
"supertest": "~3.0.0",
"tap-dot": "~1.0.5"
},
"engines": {
"node": ">=4.3.2"
}
}
Thanks! 谢谢!
Ok i managed to solve it, 好吧,我设法解决了
first thing i reinstalled the packages using 首先,我使用重新安装了软件包
npm install --save firebase-admin
and than i also did a little hack, i added to the package file: 比起我也做了一点修改,我将其添加到软件包文件中:
"scripts": {
"start": "npm install firebase-admin; node app.js"
},
which i guess isn't the best of practice, but it worked. 我猜这不是最好的做法,但是确实有效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.