Baileys: [BUG] TypeScript error - Cannot find module '@adiwajshing/baileys' or its corresponding type declarations.

Describe the bug On the import line it gives me an error - Cannot find module '@adiwajshing/baileys' or its corresponding type declarations.

import makeWASocket, {DisconnectReason, makeInMemoryStore, isJidGroup, useMultiFileAuthState} from '@adiwajshing/baileys'

The same line worked fine with the previous repo, adiwajshing/baileys

To Reproduce Steps to reproduce the behavior:

  1. Install the library as dependency in TS project - yarn add github:WhiskeySockets/Baileys
  2. Run npm run build (I’m using nest for that)
  3. Observe the error.

Expected behavior It works 😃

Environment (please complete the following information):

  • node 18
  • yarn 1.22
  • typescript 4.7.4
  • What else could help here?

Additional context The same code with adiwajshing/baileys dependency from node_modules works fine. No changes made.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 16 (5 by maintainers)

Most upvoted comments

OK, do the following.

1- delete the node modules

2- delete the package.lock

3- run -> yarn install.

4 - verify https ->“@adiwajshing/baileys”: https://github.com/WhiskeySockets/Baileys

I had the same error, when I did that it started working again and recognizing normally

image

Use “@adiwajshing/baileys”: “github: WhiskeySockets/Baileys”,

Now you can install using npm install @whiskeysockets/baileys or yarn add @whiskeysockets/baileys - https://whiskeysockets.github.io/docs/intro

You can use the git version using NPM or Yarn V2, the Yarn v1 (classic) will not work.

OK, do the following.

1- delete the node modules

2- delete the package.lock

3- run -> yarn install.

4 - verify https ->“@adiwajshing/baileys”: https://github.com/WhiskeySockets/Baileys

5- clear npm cache

I had the same error, when I did that it started working again and recognizing normally

image

uses npm, using yarn you need to run tsc manually.

If I suppress it with // @ts-ignore it shows

Error: Cannot find module '/home/allburov/git/project/node_modules/@adiwajshing/baileys/lib/index.js'. Please verify that the package.json has a valid "main" entry