Loh*_*eek 8 google-app-engine node.js firebase google-cloud-platform google-cloud-firestore
我已经使用node.js 标准环境在AppEngine上部署了一个 cron ,以便定期更新我的 Firestore 数据库。
在此文档之后,链接到此可用 npm 模块列表,我应该可以使用@google-cloud/firestore,但之后:
npm i --save @google-cloud/firestore
我收到以下错误:
Error: Cannot find module '@google-cloud/firestore'
在线:
var firestore = require('@google-cloud/firestore');
Run Code Online (Sandbox Code Playgroud)
我的 package.json 与 Hello World 示例相同:
{
"name": "appengine-hello-world",
"description": "Simple Hello World Node.js sample for Google App Engine Standard Environment.",
"version": "0.0.1",
"private": true,
"license": "Apache-2.0",
"author": "Google Inc.",
"repository": {
"type": "git",
"url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git"
},
"engines": {
"node": "8.x.x"
},
"scripts": {
"deploy": "gcloud app deploy",
"start": "node app.js",
"lint": "repo-tools lint",
"pretest": "npm run lint",
"system-test": "repo-tools test app",
"test": "npm run system-test",
"e2e-test": "repo-tools test deploy"
},
"dependencies": {
"@google-cloud/firestore": "^0.14.1",
"express": "^4.16.3"
},
"devDependencies": {
"@google-cloud/nodejs-repo-tools": "^2.3.0",
"semistandard": "^12.0.1"
},
"cloud-repo-tools": {
"test": {
"app": {
"msg": "Hello, world!"
}
},
"requiresKeyFile": true,
"requiresProjectId": true
}
}
Run Code Online (Sandbox Code Playgroud)
最后我部署:
gcloud app deploy --version=v8 --promote
Run Code Online (Sandbox Code Playgroud)
我应该如何在我的 cron 中使用 firestore ?
安装好像有问题@grpc
。如果您@grpc
因之前的安装尝试而损坏,如果您继续尝试安装,它可能会一直失败。这样做npm install @google-cloud/firestore
还会尝试安装 grpc,因此如果 grpc 损坏,整个过程将无法成功完成。
尝试删除整个nodes_modules
文件夹并从头开始安装软件包。
至于为什么 grpc 首先被损坏,我不太确定。从我的 Windows Shell 命令 (cmd.exe) 进行的任何全新安装都一遍又一遍地给我同样的问题。
但是,我能够使用 Ubuntu 的 linux 终端在 Ubuntu 虚拟机上成功安装所有内容。后来我意识到即使在使用 Windows 的 Linux 子系统而不是 Shell 命令的 Windows 操作系统上也可能发生同样的事情(这是一个视频,展示了如何为 Windows 设置 Ubuntu 终端)。所以外壳命令似乎是问题所在。出于某种我还没有研究过的原因,它不适用于某些@google-cloud/*
软件包。
话虽如此,也可以使用Cmder 之类的东西或 Shell 命令以外的任何东西在 Windows 上正确安装这些软件包(我无法确认,我还没有尝试过)。
归档时间: |
|
查看次数: |
2809 次 |
最近记录: |