[英]Cannot find module 'google-cloud/pubsub' when deploying app
I'm currently working on a google cloud project that involves moving data from PubSub to Datastore. 我目前正在研究一个Google云项目,该项目涉及将数据从PubSub移到Datastore。 This is being run on a google cloud appengine instance that is running as a resident application.
这是在作为常驻应用程序运行的google cloud appengine实例上运行的。 I started working on the datastore part first with no trouble, but when it came to supporting pubsub the app crashes when I try to include it.
我首先毫无困难地开始研究数据存储部分,但是当涉及到支持pubsub时,当我尝试包含它时应用崩溃了。
//including datastore
const Datastore = require('@google-cloud/datastore');
const datastore = Datastore();
//including pubsub
const PubSub = require('@google-cloud/pubsub');
const pubsub = new PubSub();
What I don't understand is how these two commands are practically identical and only the pubsub part crashes. 我不明白的是,这两个命令实际上是一样的,只有pubsub部分崩溃。 The google-cloud documentation lays this out as the way to include pubsub into the project.
google-cloud文档将其设计为将pubsub包含到项目中的方式。 I also tried loading the package locally through npm with no success.
我还尝试通过npm在本地加载软件包,但没有成功。
What can be done to alleviate this issue? 可以采取什么措施缓解此问题? Thanks in advance.
提前致谢。
I've found the source of the error. 我找到了错误的来源。 In the package.json file, I had forgotten to include pubsub as a dependency.
在package.json文件中,我忘记了将pubsub作为依赖项。 The updated dependencies reads as follows
更新后的依赖项如下
"dependencies": {
"@google-cloud/datastore": "1.3.4",
"@google-cloud/pubsub": "0.19.0",
"express": "4.16.2"
},
The app now deploys without any problems. 现在,该应用程序已部署,没有任何问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.