Coder Social home page Coder Social logo

NPM about baileys HOT 43 CLOSED

whiskeysockets avatar whiskeysockets commented on August 15, 2024
NPM

from baileys.

Comments (43)

Marcoant007 avatar Marcoant007 commented on August 15, 2024 3

You don't need yarn anymore using the normal npm already get the latest version and it works perfectly.

https://www.npmjs.com/package/@whiskeysockets/baileys

from baileys.

PurpShell avatar PurpShell commented on August 15, 2024 2

We are working on this, we have an NPM org ready

from baileys.

andresayac avatar andresayac commented on August 15, 2024 1

you don't need to use the npmjs.com package you can use yarn add github:WhiskeySockets/Baileys instead while the release is being fixed

from baileys.

Teamolduser avatar Teamolduser commented on August 15, 2024 1

you don't need to use the npmjs.com package you can use yarn add github:WhiskeySockets/Baileys instead while the release is being fixed

but i want a single auth one system so i ask to you

but i want so how can i upload 4.4.0 in my npm

from baileys.

Teamolduser avatar Teamolduser commented on August 15, 2024 1

Did it. same error

Baileys, package.json file contains "main": "lib/index.js", but that file is clearly not present in the code

https://github.com/WhiskeySockets/Baileys/blob/master/package.json

I wonder why

still having issue try yarn add @adiwajshing/baileys@npm:@queenanya/[email protected]

from baileys.

andresayac avatar andresayac commented on August 15, 2024

I have not had a problem generating the package. Be careful, I do not rule out that it is not like that, I am new

https://github.com/WhiskeySockets/Baileys/blob/master/.github/workflows/publish-release.yml

image
image

from baileys.

Teamolduser avatar Teamolduser commented on August 15, 2024

I have not had a problem generating the package. Be careful, I do not rule out that it is not like that, I am new

https://github.com/WhiskeySockets/Baileys/blob/master/.github/workflows/publish-release.yml

image image

Can i publish in my npm

from baileys.

Teamolduser avatar Teamolduser commented on August 15, 2024

I have not had a problem generating the package. Be careful, I do not rule out that it is not like that, I am new

https://github.com/WhiskeySockets/Baileys/blob/master/.github/workflows/publish-release.yml

image image

how can i publish @adiwajshing/[email protected] in my npm after i clone from npm of @adiwajshin/[email protected]

from baileys.

Teamolduser avatar Teamolduser commented on August 15, 2024

you don't need to use the npmjs.com package you can use yarn add github:WhiskeySockets/Baileys instead while the release is being fixed

but i want a single auth one system so i ask to you

from baileys.

andresayac avatar andresayac commented on August 15, 2024

The truth is that I have not understood very well, when you say single auth

from baileys.

dhirennjaypal avatar dhirennjaypal commented on August 15, 2024

I used to use this module via require()
but it no longer works
i gives me this error
Cannot find module '...\node_modules\@adiwajshing\baileys\lib\index.js'

from baileys.

andresayac avatar andresayac commented on August 15, 2024

I used to use this module via require()
but it no longer works
i gives me this error
Cannot find module '...\node_modules\@adiwajshing\baileys\lib\index.js'

share screenshot of your package.json

from baileys.

choopchik avatar choopchik commented on August 15, 2024

I used to use this module via require()
but it no longer works
i gives me this error
Cannot find module '...\node_modules\@adiwajshing\baileys\lib\index.js'

share screenshot of your package.json

image

I'm trying to have Electron load the WhatsApp Web UI directly and use Baileys to connect to the same WebSocket.

preload.js:


const { contextBridge, ipcRenderer, webFrame } = require('electron');
const { WAConnection } = require('@adiwajshing/baileys');
const fs = require('fs');

contextBridge.exposeInMainWorld('electron', {
  interceptWebSocket: () => {
    ipcRenderer.send('intercept-websocket');
  },
});

ipcRenderer.on('intercept-websocket', async () => {
  const interceptWebSocket = `
    const originalWebSocket = WebSocket;
  
    WebSocket = function (...args) {
      const ws = new originalWebSocket(...args);
      if (args[0].includes('wss://web.whatsapp.com/ws')) {
        window.electron.interceptWebSocket(args[0]);
      }
      return ws;
    };
  
    WebSocket.prototype = originalWebSocket.prototype;
  `;

  ipcRenderer.send('execute-script', interceptWebSocket);
});

ipcRenderer.on('execute-script', (event, script) => {
  webFrame.executeJavaScript(script);
});

ipcRenderer.on('intercept-websocket', async (event, webSocketUrl) => {
  const conn = new WAConnection();

  conn.logger.level = 'warn';
  conn.autoReconnect = true;
  conn.connectOptions.timeoutMs = 60 * 1000;

  conn.on('connecting', () => {
    console.log('Connecting to WhatsApp...');
  });

  conn.on('open', () => {
    console.log('Connected to WhatsApp');
    fs.writeFileSync('./auth_info.json', JSON.stringify(conn.base64EncodedAuthInfo(), null, 2));
  });

  conn.on('close', ({ reason, isReconnecting }) => {
    console.log('Disconnected from WhatsApp:', reason, 'Reconnecting:', isReconnecting);
  });

  conn.on('message-new', (message) => {
    const sender = message.key.remoteJid;
    const text = message.message?.conversation || message.message?.extendedTextMessage?.text;
    if (text) {
      console.log(`New message from ${sender}: ${text}`);
    }
  });

  try {
    if (fs.existsSync('./auth_info.json')) {
      const authInfo = JSON.parse(fs.readFileSync('./auth_info.json', 'utf-8'));
      conn.loadAuthInfo(authInfo);
    }
    await conn.connect();
  } catch (error) {
    console.error('Error connecting to WhatsApp:', error);
  }
});

Error:

Error: Cannot find module '/home/user/dev/wa-desktop/node_modules/@adiwajshing/baileys/lib/index.js'. Please verify that the package.json has a valid "main" entry
    at tryPackage (node:internal/modules/cjs/loader:416:19)
    at Module._findPath (node:internal/modules/cjs/loader:658:18)
    at Module._resolveFilename (node:internal/modules/cjs/loader:1040:27)
    at o._resolveFilename (node:electron/js2c/renderer_init:2:3879)
    at Module._load (node:internal/modules/cjs/loader:900:27)
    at f._load (node:electron/js2c/asar_bundle:2:13330)
    at o._load (node:electron/js2c/renderer_init:2:3109)
    at Module.require (node:internal/modules/cjs/loader:1120:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (/home/user/dev/wa-desktop/app/view_preload.js:3:26)
(```

from baileys.

Teamolduser avatar Teamolduser commented on August 15, 2024

I used to use this module via require() but it no longer works i gives me this error Cannot find module '...\node_modules\@adiwajshing\baileys\lib\index.js'

From where you clone or download this

from baileys.

choopchik avatar choopchik commented on August 15, 2024

I used to use this module via require() but it no longer works i gives me this error Cannot find module '...\node_modules\@adiwajshing\baileys\lib\index.js'

From where you clone or download this

yarn add github:WhiskeySockets/Baileys

from baileys.

Teamolduser avatar Teamolduser commented on August 15, 2024

I used to use this module via require() but it no longer works i gives me this error Cannot find module '...\node_modules\@adiwajshing\baileys\lib\index.js'

From where you clone or download this

yarn add github:WhiskeySockets/Baileys

in which bot

from baileys.

choopchik avatar choopchik commented on August 15, 2024

in which bot

Don't understand the question (?)

from baileys.

Teamolduser avatar Teamolduser commented on August 15, 2024

in which bot

Don't understand the question (?)

In which folder you cloned or download it

from baileys.

choopchik avatar choopchik commented on August 15, 2024

I ran yarn add github:WhiskeySockets/Baileys from the top folder of the project.

from baileys.

Teamolduser avatar Teamolduser commented on August 15, 2024

I ran yarn add github:WhiskeySockets/Baileys from the top folder of the project.

Can you give a folder link ?

from baileys.

choopchik avatar choopchik commented on August 15, 2024

Folder link?, you mean: /home/user/dev/wa-desktop/

In the error message, it says:
`Cannot find module '...\node_modules@adiwajshing\baileys\lib\index.js'

But when looking at the Baileys files inside node_modules, the 'lib\index.js' file isn't there. Could this be because Baileys uses TypeScript (.ts) while my project is in JavaScript (.js)?
screenshot:
image

from baileys.

andresayac avatar andresayac commented on August 15, 2024

you are going the other way, the method indicated does not exist WAConnection

if you want to build you should use const { makeWASocket } = require('@adiwajshing/baileys');
image

from baileys.

Teamolduser avatar Teamolduser commented on August 15, 2024

const { makeWASocket } = require('@adiwajshing/baileys');

const { makeWASocket } = require('@adiwajshing/baileys');.default

from baileys.

choopchik avatar choopchik commented on August 15, 2024

changed to const { makeWASocket } = require('@adiwajshing/baileys');
Still getting the same error:

Error: Cannot find module '/home/user/dev/wa-desktop/node_modules/@adiwajshing/baileys/lib/index.js'. Please verify that the package.json has a valid "main" entry
    at tryPackage (node:internal/modules/cjs/loader:416:19)
    at Module._findPath (node:internal/modules/cjs/loader:658:18)
    at Module._resolveFilename (node:internal/modules/cjs/loader:1040:27)
    at o._resolveFilename (node:electron/js2c/renderer_init:2:3879)
    at Module._load (node:internal/modules/cjs/loader:900:27)
    at f._load (node:electron/js2c/asar_bundle:2:13330)
    at o._load (node:electron/js2c/renderer_init:2:3109)
    at Module.require (node:internal/modules/cjs/loader:1120:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (/home/user/dev/assitant-desktop/app/view_preload.js:3:26)
(

from baileys.

choopchik avatar choopchik commented on August 15, 2024

This is the package.json of my Baileys:

{
  "name": "@adiwajshing/baileys",
  "version": "5.0.0",
  "description": "WhatsApp API",
  "homepage": "https://github.com/adiwajshing/Baileys",
  "main": "lib/index.js",
  "types": "lib/index.d.ts",
  "keywords": [
    "whatsapp",
    "js-whatsapp",
    "whatsapp-api",
    "whatsapp-web",
    "whatsapp",
    "whatsapp-chat",
    "whatsapp-group",
    "automation",
    "multi-device"
  ],
  "scripts": {
    "test": "jest",
    "prepare": "tsc",
    "build:all": "tsc && typedoc",
    "build:docs": "typedoc",
    "build:tsc": "tsc",
    "example": "node --inspect -r ts-node/register Example/example.ts",
    "gen:protobuf": "sh WAProto/GenerateStatics.sh",
    "lint": "eslint . --ext .js,.ts,.jsx,.tsx",
    "lint:fix": "eslint . --fix --ext .js,.ts,.jsx,.tsx"
  },
  "author": "Adhiraj Singh",
  "license": "MIT",
  "repository": {
    "url": "[email protected]:adiwajshing/baileys.git"
  },
  "dependencies": {
    "@hapi/boom": "^9.1.3",
    "axios": "^1.3.3",
    "futoin-hkdf": "^1.5.1",
    "libsignal": "https://github.com/adiwajshing/libsignal-node.git",
    "music-metadata": "^7.12.3",
    "node-cache": "^5.1.2",
    "pino": "^7.0.0",
    "protobufjs": "^6.11.3",
    "ws": "^8.0.0"
  },
  "peerDependencies": {
    "@adiwajshing/keyed-db": "^0.2.4",
    "jimp": "^0.16.1",
    "link-preview-js": "^3.0.0",
    "qrcode-terminal": "^0.12.0",
    "sharp": "^0.30.5"
  },
  "peerDependenciesMeta": {
    "@adiwajshing/keyed-db": {
      "optional": true
    },
    "jimp": {
      "optional": true
    },
    "qrcode-terminal": {
      "optional": true
    },
    "sharp": {
      "optional": true
    },
    "link-preview-js": {
      "optional": true
    }
  },
  "files": [
    "lib/*",
    "WAProto/*",
    "WASignalGroup/*.js"
  ],
  "devDependencies": {
    "@adiwajshing/eslint-config": "https://github.com/adiwajshing/eslint-config.git",
    "@adiwajshing/keyed-db": "^0.2.4",
    "@types/got": "^9.6.11",
    "@types/jest": "^27.5.1",
    "@types/node": "^16.0.0",
    "@types/sharp": "^0.29.4",
    "@types/ws": "^8.0.0",
    "eslint": "^8.0.0",
    "jest": "^27.0.6",
    "jimp": "^0.16.1",
    "link-preview-js": "^3.0.0",
    "qrcode-terminal": "^0.12.0",
    "sharp": "^0.30.5",
    "ts-jest": "^27.0.3",
    "ts-node": "^10.8.1",
    "typedoc": "^0.22.0",
    "typescript": "^4.0.0"
  }
}

from baileys.

Teamolduser avatar Teamolduser commented on August 15, 2024

``

changed to const { makeWASocket } = require('@adiwajshing/baileys'); Still getting the same error:

Error: Cannot find module '/home/user/dev/wa-desktop/node_modules/@adiwajshing/baileys/lib/index.js'. Please verify that the package.json has a valid "main" entry
    at tryPackage (node:internal/modules/cjs/loader:416:19)
    at Module._findPath (node:internal/modules/cjs/loader:658:18)
    at Module._resolveFilename (node:internal/modules/cjs/loader:1040:27)
    at o._resolveFilename (node:electron/js2c/renderer_init:2:3879)
    at Module._load (node:internal/modules/cjs/loader:900:27)
    at f._load (node:electron/js2c/asar_bundle:2:13330)
    at o._load (node:electron/js2c/renderer_init:2:3109)
    at Module.require (node:internal/modules/cjs/loader:1120:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (/home/user/dev/assitant-desktop/app/view_preload.js:3:26)
(

use yarn add @adiwajshing/baileys@github:WhiskeySockets

from baileys.

choopchik avatar choopchik commented on August 15, 2024
$ yarn add @adiwajshing/baileys@github:WhiskeySockets
yarn add v1.22.19
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/4] Resolving packages...
error Invalid hosted git fragment "github:WhiskeySockets".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

from baileys.

Teamolduser avatar Teamolduser commented on August 15, 2024
$ yarn add @adiwajshing/baileys@github:WhiskeySockets
yarn add v1.22.19
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/4] Resolving packages...
error Invalid hosted git fragment "github:WhiskeySockets".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

try to run with npm i @adiwajshing/baileys@github:WhiskeySockets

from baileys.

choopchik avatar choopchik commented on August 15, 2024
$ npm i @adiwajshing/baileys@github:WhiskeySockets
npm ERR! code 128
npm ERR! An unknown git error occurred
npm ERR! command git --no-replace-objects ls-remote ssh://[email protected]/null/WhiskeySockets.git
npm ERR! [email protected]: Permission denied (publickey).
npm ERR! fatal: Could not read from remote repository.
npm ERR! 
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/user/.npm/_logs/2023-05-03T21_27_16_831Z-debug-0.log

from baileys.

Teamolduser avatar Teamolduser commented on August 15, 2024
$ npm i @adiwajshing/baileys@github:WhiskeySockets
npm ERR! code 128
npm ERR! An unknown git error occurred
npm ERR! command git --no-replace-objects ls-remote ssh://[email protected]/null/WhiskeySockets.git
npm ERR! [email protected]: Permission denied (publickey).
npm ERR! fatal: Could not read from remote repository.
npm ERR! 
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/user/.npm/_logs/2023-05-03T21_27_16_831Z-debug-0.log

can you told me what are you trying to do

from baileys.

Teamolduser avatar Teamolduser commented on August 15, 2024
$ npm i @adiwajshing/baileys@github:WhiskeySockets
npm ERR! code 128
npm ERR! An unknown git error occurred
npm ERR! command git --no-replace-objects ls-remote ssh://[email protected]/null/WhiskeySockets.git
npm ERR! [email protected]: Permission denied (publickey).
npm ERR! fatal: Could not read from remote repository.
npm ERR! 
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/user/.npm/_logs/2023-05-03T21_27_16_831Z-debug-0.log

try this yarn add @adiwajshing/baileys@github:WhiskeySockets/baileys

from baileys.

choopchik avatar choopchik commented on August 15, 2024

can you told me what are you trying to do

To require Baileys into my project

from baileys.

Teamolduser avatar Teamolduser commented on August 15, 2024

can you told me what are you trying to do

To require Baileys into my project

which project

from baileys.

choopchik avatar choopchik commented on August 15, 2024

whatsapp desktop app using electron

from baileys.

Teamolduser avatar Teamolduser commented on August 15, 2024

whatsapp desktop app using electron

oh

try this yarn add @adiwajshing/baileys@github:WhiskeySockets/baileys

if this will show trouble with network then use npm i instead of yarn add

from baileys.

choopchik avatar choopchik commented on August 15, 2024

still brings me the same error for require

Eror: Cannot find module '/home/user/dev/wa-desktop/node_modules/@adiwajshing/baileys/lib/index.js'. Please verify that the package.json has a valid "main" entry
    at tryPackage (node:internal/modules/cjs/loader:416:19)
    at Module._findPath (node:internal/modules/cjs/loader:658:18)
    at Module._resolveFilename (node:internal/modules/cjs/loader:1040:27)
    at o._resolveFilename (node:electron/js2c/renderer_init:2:3879)
    at Module._load (node:internal/modules/cjs/loader:900:27)
    at f._load (node:electron/js2c/asar_bundle:2:13330)
    at o._load (node:electron/js2c/renderer_init:2:3109)
    at Module.require (node:internal/modules/cjs/loader:1120:19)
    at require (node:internal/modules/cjs/helpers:103:18)
 

from baileys.

Teamolduser avatar Teamolduser commented on August 15, 2024

still brings me the same error for require

Eror: Cannot find module '/home/user/dev/wa-desktop/node_modules/@adiwajshing/baileys/lib/index.js'. Please verify that the package.json has a valid "main" entry
    at tryPackage (node:internal/modules/cjs/loader:416:19)
    at Module._findPath (node:internal/modules/cjs/loader:658:18)
    at Module._resolveFilename (node:internal/modules/cjs/loader:1040:27)
    at o._resolveFilename (node:electron/js2c/renderer_init:2:3879)
    at Module._load (node:internal/modules/cjs/loader:900:27)
    at f._load (node:electron/js2c/asar_bundle:2:13330)
    at o._load (node:electron/js2c/renderer_init:2:3109)
    at Module.require (node:internal/modules/cjs/loader:1120:19)
    at require (node:internal/modules/cjs/helpers:103:18)
 

First remove old @adiwajshing/baileys
Then try
yarn add @adiwajshing/baileys@github:WhiskeySockets/baileys

from baileys.

choopchik avatar choopchik commented on August 15, 2024

Did it. same error

Baileys, package.json file contains "main": "lib/index.js", but that file is clearly not present in the code

https://github.com/WhiskeySockets/Baileys/blob/master/package.json

I wonder why

from baileys.

Teamolduser avatar Teamolduser commented on August 15, 2024

I have not had a problem generating the package. Be careful, I do not rule out that it is not like that, I am new

https://github.com/WhiskeySockets/Baileys/blob/master/.github/workflows/publish-release.yml

image image

Then i don't know ask to @PurpShell and @andresayac

from baileys.

ahmedRSA avatar ahmedRSA commented on August 15, 2024

We are working on this, we have an NPM org ready

Is there any update on when will you release it?

from baileys.

jmedellinc avatar jmedellinc commented on August 15, 2024

I had troubles as well using baileys in a CJS node project (using require() instead of IMPORT)

They way I solved is as follows

const makeWASocketCont = require("@whiskeysockets/baileys");
const makeWASocket = makeWASocketCont.default;
const { useMultiFileAuthState, DisconnectReason } = makeWASocketCont;

from baileys.

Teamolduser avatar Teamolduser commented on August 15, 2024

You don't need yarn anymore using the normal npm already get the latest version and it works perfectly.

https://www.npmjs.com/package/@whiskeysockets/baileys

But how can u install module now a days npm has some issue than the other option is yarn to use

from baileys.

Teamolduser avatar Teamolduser commented on August 15, 2024

I had troubles as well using baileys in a CJS node project (using require() instead of IMPORT)

They way I solved is as follows

const makeWASocketCont = require("@whiskeysockets/baileys");
const makeWASocket = makeWASocketCont.default;
const { useMultiFileAuthState, DisconnectReason } = makeWASocketCont;

You can use
const makeWASocket = require("@whiskeysockets/baileys").default;

from baileys.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.