简体   繁体   中英

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. This is being run on a google cloud appengine instance that is running as a resident application. 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.

//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. The google-cloud documentation lays this out as the way to include pubsub into the project. I also tried loading the package locally through npm with no success.

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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM