ookamiiixd / baileys-api

Simple WhatsApp REST API with multiple device support
MIT License
433 stars 329 forks source link

Running "npm install" #152

Closed jhernancanom closed 1 year ago

jhernancanom commented 1 year ago

Hello, friends.

When I run npm install, I am getting the errs show in the image. I aso attach the .log.

How should I proceed?

image

2023-02-20T03_33_47_630Z-debug-0.log

ookamiiixd commented 1 year ago

I'm not sure, have you tried searching solution in the internet?

netrixken commented 1 year ago

can confirm this. also after npm install success & running npm build got error:

> baileys-api@1.0.0-beta.0 build
> tsc

src/controllers/chat.ts:16:12 - error TS7006: Parameter 'c' implicitly has an 'any' type.

16     ).map((c) => serializePrisma(c));
              ~

src/controllers/chat.ts:42:12 - error TS7006: Parameter 'm' implicitly has an 'any' type.

42     ).map((m) => serializePrisma(m));
              ~

src/controllers/message.ts:20:12 - error TS7006: Parameter 'm' implicitly has an 'any' type.

20     ).map((m) => serializePrisma(m));
              ~

src/shared.ts:1:10 - error TS2305: Module '"@prisma/client"' has no exported member 'PrismaClient'.

1 import { PrismaClient } from '@prisma/client';
           ~~~~~~~~~~~~

Found 4 errors in 3 files.

Errors  Files
     2  src/controllers/chat.ts:16
     1  src/controllers/message.ts:20
     1  src/shared.ts:1
ookamiiixd commented 1 year ago

@netrixken, actually, i've never used npm anymore, i always use yarn instead. I'll take a look into this later

kampit commented 1 year ago

You can disable the TypeScript compiler from checking for implicit any types by adding the following line to your tsconfig.json file:

{
  "compilerOptions": {
    "noImplicitAny": false
  }
}
ookamiiixd commented 1 year ago

@netrixken i just realized that your error is most likely caused because you haven't setup your database before build. I'm sorry, this is my fault because of the wrong step in the guide

The correct step is actually after the step 3 of Installation, you have to do the Setup step before going into step 4. I'll update the guide asap

jhernancanom commented 1 year ago

Thanks, ookamiiixd.

I see that the error message is refering to git.

Dispite I don't see instructions saying that git is needed, nor how to install git, i'll try to get git installed.

jhernancanom commented 1 year ago

Hi, friends. How should I proceed? image

jhernancanom commented 1 year ago

My tryings in this week. See attached PDF for my asking this time.

I used some .BAT files for guiding myself to run the different commands; I attach them.

When I used CHECKING.BAT I discovered that I had KAWIX and KODNET with an older version of NodeJs, and --for what I see and understand-- this could be disturbing my installing of Baileys. Then I proceed to deactivate KodNet.

Thanks

Procedimiento-2023-03-04.pdf

imagenes.zip

BAT-files.zip

jhernancanom commented 1 year ago

Does the

"activeProvider": "mysql",

also needs to be changed in

.........\node_modules\.prisma\client\index.js

in line 301?

and/or in

.........\node_modules\.prisma\client\schema.prisma

????

jhernancanom commented 1 year ago

I am installing from scratch (ever and ever) (I wrote several .BAT files that help me to do it).

But when I got the Prisma-step, I am receiving a bunch of errors (I put text because it seems on GitHub we cannot put images); the errors start with (and go until line 160):


_**npx prisma db push**_

Environment variables loaded from .env

Prisma schema loaded from prisma\schema.prisma

Datasource "db": SQLite database "EMPRESA.db3" at "file:E:/baileys-waza/FACTURACION/EMPRESA.db3"

Error: P1012

error: Native type VarChar is not supported for sqlite connector.
  -->  schema.prisma:15
   |
14 |   pkId                      Int      @id @default(autoincrement())
15 |   sessionId                 String   @db.VarChar(128)
   |
error: Native type VarChar is not supported for sqlite connector.
  -->  schema.prisma:20
   |
19 |   createdAt                 BigInt?
20 |   createdBy                 String?  @db.VarChar(128)
   |
error: Native type VarChar is not supported for sqlite connector.
  -->  schema.prisma:21
   |
20 |   createdBy                 String?  @db.VarChar(128)
21 |   description               String?  @db.VarChar(255)
   |
jhernancanom commented 1 year ago

I am seeing in README main page that

Prisma supported databases (click here). Tested on MySQL and PostgreSQL.

SQLite is included in Prisma, but not in Baileys-API.

I'll wait for SQLite in Baileys-API.

What if do not wanna use a db?

What do I need to do in .ENV file to accomplish this?

jhernancanom commented 1 year ago

Hi, friends. I decided to get MySQL installed for trying to give an opportunity to new-Baileys version.

I run my scripts from zero, and I only receive the errs shown in imagen-01, when npm-run-build.

The last scripts are shown un imagen-02, and they show ok.

imagen-01

imagen-02

imagen-03

I transcript what images say, because here in GitHub I have discovered you cannot see images.

Dos the err in image-01 means that I am going to have any problem?

I am stuck in reading the QR imagen. But I do not know how to get the QR image appears..... after many tryings it appears and when I try to read it, I got an err about "The image could not been read".

If I use a JSON like { "id": "mensajes", "isLegacy":"false" } I got { "msg": "Invalid value", "param": "sessionId", "location": "body" } .

If I use a JSON like { "sessionId": "mensajes", "isLegacy":"false" } I got the same err { "msg": "Invalid value", "param": "sessionId", "location": "body" } .

========================================

From IMAGE-01:

E:\baileys-waza\baileys-api-master>2-npm-run-build.bat ...... 2-npm-run-build.bat ......

E:\baileys-waza\baileys-api-master>call E:\node-waza\2022-12-10\node-v18.12.1-win-x64\npm run build

baileys-api@1.0.0-beta.0 build tsc

src/controllers/chat.ts:16:12 - error TS7006: Parameter 'c' implicitly has an 'any' type.

16 ).map((c) => serializePrisma(c)); ~

src/controllers/chat.ts:42:12 - error TS7006: Parameter 'm' implicitly has an 'any' type.

42 ).map((m) => serializePrisma(m)); ~

src/controllers/message.ts:20:12 - error TS7006: Parameter 'm' implicitly has an 'any' type.

20 ).map((m) => serializePrisma(m)); ~

Found 3 errors in 2 files.

Errors Files 2 src/controllers/chat.ts:16 1 src/controllers/message.ts:20 npm notice npm notice New major version of npm available! 8.19.2 -> 9.6.4 npm notice Changelog: https://github.com/npm/cli/releases/tag/v9.6.4 npm notice Run npm install -g npm@9.6.4 to update! npm notice Presione una tecla para continuar . . .

========================================

From IMAGE-02:

E:\baileys-waza\baileys-api-master>3-npx-prisma-db.bat ...... 3-npx-prisma-db.bat ...... npx prisma db push

E:\baileys-waza\baileys-api-master>call npx prisma db push

Environment variables loaded from .env Prisma schema loaded from prisma\schema.prisma Datasource "db": MySQL database "baileys_api" at "localhost:3306"

Your database is now in sync with your Prisma schema. Done in 8.43s

? Generated Prisma Client (4.11.0 | library) to .\node_modules\@prisma\client in 1.80s

Presione una tecla para continuar . . .

E:\baileys-waza\baileys-api-master>4-npm-run-start.bat ...... 4-npm-run-start.bat ...... E:\node-waza\2022-12-10\node-v18.12.1-win-x64\npm run start

E:\baileys-waza\baileys-api-master>call E:\node-waza\2022-12-10\node-v18.12.1-win-x64\npm run start

baileys-api@1.0.0-beta.0 start node .

imports from "@prisma/client/runtime" are deprecated. Use "@prisma/client/runtime/library", "@prisma/client/runtime/data-proxy" or "@prisma/client/runtime/binary" Server is listening on http://localhost:3000

{"level":50,"time":1680972584638,"pid":736,"hostname":"DESKTOP-IAEMJFA","err":{"type":"NotFoundError","message":"No Session found","stack":"NotFoundError: No Session found\n at E:\baileys-waza\baileys-api-master\node_modules\@prisma\client\runtime\library.js:164:6704\n at async E:\baileys-waza\baileys-api-master\node_modules\@prisma\client\runtime\library.js:164:6643\n at async read (E:\baileys-waza\baileys-api-master\node_modules\@ookamiiixd\baileys-store\dist\session.js:28:30)\n at async useSession (E:\baileys-waza\baileys-api-master\node_modules\@ookamiiixd\baileys-store\dist\session.js:50:20)\n at async createSession (E:\baileys-waza\baileys-api-master\dist\wa.js:154:34)","code":"P2025","clientVersion":"4.11.0","name":"NotFoundError"},"msg":"An error occured during session read"}

========================================

From IMAGE-03:


The data for running the web service:

Method: POST URL : http://localhost:3000/sessions/add JSON : { "id": "mensajes", "isLegacy":"false" }

JSON : { "sessionId": "mensajes", "isLegacy":"false" }


The response of the web service:

{ "errors": [ { "msg": "Invalid value", "param": "sessionId", "location": "body" }, { "msg": "Invalid value", "param": "sessionId", "location": "body" } ]
}


jhernancanom commented 1 year ago

jhernancanom commented 1 year ago

Yesterday --after a new trying -- from scratch-- (following my own instructions written by myself since starting and documented ones) I got send several proof messages.

Unfortunatelly we need MySQL (I had to activate a minimalistic Apache server), but the main goal (send a message) was reached.

Just to say:

I would like to say more, but.... (it is very large now).

Can be closed. Thanks for sharing.