2017-11-07 11 views
0

ich eine Google-Cloud-Funktion zu implementieren versuche ich einfach nur mit den ursprünglichen Anforderungen an meine index.js Datei gestartet:Google Cloud-Funktionen: require (...) ist keine Funktion Google Cloud

// Import the Google Cloud client libraries 
const nl = require('@google-cloud/language')(); 
const speech = require('@google-cloud/speech')(); 
const storage = require('@google-cloud/storage')(); 

Aber ich bekomme die folgende Meldung bei der Bereitstellung:

Detailed stack trace: TypeError: require(...) is not a function 

Dies geschieht nur mit der @ google-Wolke/Sprache und @ google-Cloud/Sprachmodule, die @ google-Cloud/Speichermodul ist als ein geladene Fein Funktion (Ich testete, indem ich die ersten beiden kommentierte).

Jede Beratung wird sehr geschätzt.

Borrigan

+0

Alle Nachrichten dazu? Mit dem gleichen Problem konfrontiert. – galgo

+0

Ich habe herausgefunden, dass zumindest das Sprachpaket Umgebungsvariablen verwendet – galgo

Antwort

0
Google cloud function are nodejs modules so the syntax is same as nodejs syntax. 

Regarding your problem: 

you have to write 
const storage = require('@google-cloud/storage'); 
(without() at the end of each statement) 

So the correct declaration will be: 

// Import the Google Cloud client libraries 
const nl = require('@google-cloud/language'); 
const speech = require('@google-cloud/speech'); 
const storage = require('@google-cloud/storage'); 

I hope this helps. 
Verwandte Themen