Module not found when initializing Chat API

Aperta
#3,425 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
28/100
Tipo di issue
Bug
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
javascript, node.js
Ambito
api, backend

Direzione di ricerca

Inizia riproducendo il problema con npm run start usando la versione ^21.0.0 di @googleapis/chat e ispeziona la posizione nello stack di gaxios, oltre ai metadati del pacchetto https-proxy-agent installato. Confronta lo stato delle dipendenze con googleapis 17.0.1, segnalato come funzionante; il lavoro è completato quando viene identificata una risoluzione riproducibile e viene confermato che l’inizializzazione di Chat API riesce.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
TypeScript
Stelle
12.3k
Fork
2k
Merge medio
3g 10h
PR unite (30g)
9

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di googleapis/google-api-nodejs-client

Tutte le issue di googleapis/google-api-nodejs-client

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.