Module not found when initializing Chat API

Offen
#3,425 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 2 Tagen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
28/100
Issue-Typ
Bug
Klarheit
Muss geklärt werden
Aktivitätsstatus
Veraltet
Tech-Stack
javascript, node.js
Bereich
api, backend

Rechercherichtung

Beginne damit, den Fehler mit npm run start unter Verwendung der Version ^21.0.0 von @googleapis/chat zu reproduzieren, und untersuche die Position im gaxios-Stack sowie die Metadaten des installierten Pakets https-proxy-agent. Vergleiche den Abhängigkeitsstatus mit dem gemeldeten funktionierenden googleapis 17.0.1; abgeschlossen ist die Aufgabe, wenn eine reproduzierbare Auflösung identifiziert und bestätigt wurde, dass die Initialisierung der Chat API erfolgreich ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

priority: p2 type: bug
Environment details
  • OS: Windows 11
  • Node.js version: 16.0.0
  • npm version: 7.4.0
  • googleapis version: ^21.0.0
Steps to reproduce

I'm getting the following error when trying to use the chat API. When I run npm run start I get:

Error: Cannot find module 'C:\Users\Martin Carrasco\Desktop\BurnoutZero\boz-google-chat-app\node_modules\https-proxy-agent\dist\index.js'. Please verify that the package.json has a valid "main" entry   
    at Module._findPath (node:internal/modules/cjs/loader:720:18)
    at Module._resolveFilename (node:internal/modules/cjs/loader:1135:27)
    at Module._load (node:internal/modules/cjs/loader:990:27)
    at Module.require (node:internal/modules/cjs/loader:1237:19)
    at require (node:internal/modules/helpers:176:18)
    at Object.<anonymous> (C:\Users\Martin Carrasco\Desktop\BurnoutZero\boz-google-chat-app\node_modules\gaxios\build\src\gaxios.js:27:29)
    at Module._extensions..js (node:internal/modules/cjs/loader:1437:10)
    at Module.load (node:internal/modules/cjs/loader:1212:32) {
  code: 'MODULE_NOT_FOUND',
  path: 'C:\\Users\\Martin Carrasco\\Desktop\\BurnoutZero\\boz-google-chat-app\\node_modules\\https-proxy-agent\\package.json',
  requestPath: 'https-proxy-agent'
}

And here is my code:

const chat = require('@googleapis/chat');

async function createMessage() {
  const auth = new chat.auth.GoogleAuth({

    // Specify service account details.
    keyFilename: 'credentials.json',

    // Specify required scopes.
    scopes: ['https://www.googleapis.com/auth/chat.bot']

  });
  const authClient = await auth.getClient();

  // Create the Chat API client and authenticate with the service account.
  const chatClient = await chat.chat({
    version: 'v1',
    auth: authClient
  });

  // Create a Chat message.
  const result = await chatClient.spaces.messages.create({

    // The space to create the message in.
    //
    // Replace SPACE_NAME with a space name.
    // Obtain the space name from the spaces resource of Chat API,
    // or from a space's URL.
    parent: 'spaces/AAAAxqmzN8I',

    // The message to create.
    requestBody: { 'text': 'Hello, world!' }

  });
  return result;
}

// Execute function then print details about the created message.
(async() => {
    const r = await createMessage();
    console.log(r);
})()

I tried using all this node versions:

  • 21.6.1 (Currently using 64-bit executable)
    21.6.0
    20.11.0
    18.0.0
    17.0.0

with no success. The only thing that worked for my was downgrading my googlechat api version to 17.0.1

Vorherrschende Sprache
TypeScript
Sterne
12.3k
Forks
2k
Ø Merge
3 T. 10 Std.
Gemergte PRs (30 T.)
9

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus googleapis/google-api-nodejs-client

Alle Issues in googleapis/google-api-nodejs-client

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.