简体   繁体   English

部署应用程序时找不到模块“ google-cloud / pubsub”

[英]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.

相关问题 @google-cloud/pubsub TypeError:无法读取未定义的属性“状态” - @google-cloud/pubsub TypeError: Cannot read property 'status' of undefined 如何使用Google PubSub(@ google-cloud / pubsub)进行确认 - How to ACK using Google PubSub (@google-cloud/pubsub) 使用 node.js 标准环境在 AppEngine 上找不到模块 @google-cloud/firestore - Cannot find module @google-cloud/firestore on AppEngine using node.js standard environment 将 node.js 应用程序部署到谷歌云平台时找不到模块“yargs”错误 - Cannot find module 'yargs' error while deploying node.js app to google cloud platform 将Node.js应用程序部署到Google App Engine时出现“找不到模块” - “Cannot find module” when deploying Node.js app to Google App Engine 找不到模块:无法解析 @google-cloud/storage 上的“fs” - Module not found: Can't resolve 'fs' on @google-cloud/storage Vue JS不支持Module @ google-cloud / speech? - Module @google-cloud/speech not supported for Vue JS? 部署到Heroku时找不到mongoDB模块 - Cannot find mongoDB module when deploying to Heroku 部署到Heroku时在grunt上找不到模块 - Cannot find module on grunt when deploying to Heroku Vuejs 应用程序中的谷歌云/文本到语音验证 - google-cloud/text-to-speech authentification in Vuejs App
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM