bdsoha / vitrea-client

🏠 Vitrea Smart Home API Client
MIT License
5 stars 1 forks source link

Cannot find module 'Vitrea-Client' or its corresponding type declarations. #33

Open smartnakh opened 3 weeks ago

smartnakh commented 3 weeks ago

First Check

Example Code

import {
    ProtocolVersion,
    Requests,
    VitreaClient
} from 'Vitrea-Client'

const client = VitreaClient.create({
    host:     '192.168.1.111',
    port:     1234,
    username: 'admin',
    password: 'secret',
    version:  ProtocolVersion.V1
})

await client.connect()

await client.send(new Requests.RoomCount())

Description

Hi,

I tried to compile the script and i am getting this error

s@mbox:~/volumes/v2 $ sudo tsc index.ts
index.ts:5:8 - error TS2307: Cannot find module 'Vitrea-Client' or its corresponding type declarations.

5 } from 'Vitrea-Client'
         ~~~~~~~~~~~~~~~

index.ts:16:1 - error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.

16 await client.connect()
   ~~~~~

index.ts:18:1 - error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.

18 await client.send(new Requests.RoomCount())
   ~~~~~

Found 3 errors in the same file, starting at: index.ts:5

i am using the include in the tsconfig.json "include": ["src/**/*"]

Please, help me to find what i am missing

Raw Data

No response

Package Version

1.0.0

Protocol Version

V2 (Default)

NodeJS Version

20.16.0

Are you willing to submit PR?

bdsoha commented 3 weeks ago

Try 'vitrea-client' with lowercase letters.

smartnakh commented 2 weeks ago

Thanks for your reply

i have still the same issue

error TS2307: Cannot find module 'vitrea-client' or its corresponding type declarations.

5 } from 'vitrea-client'
bdsoha commented 2 weeks ago

How did you install the package?

smartnakh commented 2 weeks ago

Thanks for your answer


smh@mbox:~/volumes/v2 $ npm list
gn@1.0.0 /home/smh/volumes/v2
└── vitrea-client@0.0.1-alpha.0 (git+ssh://git@github.com/bdsoha/vitrea-client.git#63ec5195c40fe15e363a3daa6de4b21468a18c45)

smh@mbox:~/volumes/v2 $ sudo npm install bdsoha/vitrea-client

up to date, audited 4 packages in 14s

found 0 vulnerabilities
smh@mbox:~/volumes/v2 $ 
bdsoha commented 2 weeks ago

Are you using TS? Any compilers in place?

smartnakh commented 2 weeks ago

I am using tsc

bdsoha commented 2 weeks ago

Sorry for the hassle.

I just published a release (alpha) to npmjs.org, which should resolve the proper creation of the dist folder in node_modules. Try completely remove the existing dependency and reinstall it using npm install vitrea-client *(instead of via git+ssh://....

smartnakh commented 2 weeks ago

Thanks for your help

i am getting this error

smh@mbox:/ $ sudo npm install vitrea-client
npm error Tracker "idealTree" already exists
npm error A complete log of this run can be found in: /root/.npm/_logs/2024-08-26T07_54_19_971Z-debug-0.log
bdsoha commented 2 weeks ago

You are trying to install a package in the root directory /, that can't be done. Move to a new folder and rerun the install:

mkdir /app
cd /app
npm init -y
npm install vitrea-client
smartnakh commented 2 weeks ago

thank you for you guidance @bdsoha

i made some progress, i got to this point


smh@mbox:~/volumes/vitreabh/app $ tsc app.ts

app.ts:16:1 - error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.

16 await client.connect()
   ~~~~~

app.ts:18:1 - error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.

18 await client.send(new Requests.RoomCount())
   ~~~~~

node_modules/vitrea-client/dist/VitreaClient.d.ts:14:28 - error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.

14     protected onData(data: Buffer): void;
                              ~~~~~~

node_modules/vitrea-client/dist/VitreaClient.d.ts:15:35 - error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.

15     protected onUnknownData(data: Buffer): void;
                                     ~~~~~~

node_modules/vitrea-client/dist/core/BaseRequest.d.ts:5:14 - error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.

5     build(): Buffer;
               ~~~~~~

node_modules/vitrea-client/dist/core/BaseResponse.d.ts:4:28 - error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.

4     constructor(rawBuffer: Buffer | number[]);
                             ~~~~~~

node_modules/vitrea-client/dist/core/DataGram.d.ts:28:29 - error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.

28     constructor(rawBuffer?: Buffer | number[]);
                               ~~~~~~

node_modules/vitrea-client/dist/socket/AbstractHeartbeatHandler.d.ts:4:23 - error TS2503: Cannot find namespace 'NodeJS'.

4     protected timer?: NodeJS.Timeout;
                        ~~~~~~

node_modules/vitrea-client/dist/socket/AbstractHeartbeatHandler.d.ts:11:48 - error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.

11     protected abstract getHeartbeatDataGram(): Buffer;
                                                  ~~~~~~

node_modules/vitrea-client/dist/socket/AbstractSocket.d.ts:1:30 - error TS2307: Cannot find module 'events' or its corresponding type declarations.

1 import { EventEmitter } from 'events';
                               ~~~~~~~~

node_modules/vitrea-client/dist/socket/AbstractSocket.d.ts:5:22 - error TS2307: Cannot find module 'net' or its corresponding type declarations.

5 import * as Net from 'net';
                       ~~~~~

node_modules/vitrea-client/dist/socket/AbstractSocket.d.ts:23:17 - error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.

23     write(data: Buffer): Promise<void>;
                   ~~~~~~

node_modules/vitrea-client/dist/socket/AbstractSocket.d.ts:28:37 - error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.

28     protected abstract onData(data: Buffer): void;
                                       ~~~~~~

node_modules/vitrea-client/dist/socket/AbstractSocket.d.ts:29:44 - error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.

29     protected abstract onUnknownData(data: Buffer): void;
                                              ~~~~~~

node_modules/vitrea-client/dist/socket/WritableSocketContract.d.ts:2:17 - error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.

2     write(data: Buffer): Promise<void>;
                  ~~~~~~

Found 15 errors in 8 files.

Errors  Files
     2  app.ts:16
     2  node_modules/vitrea-client/dist/VitreaClient.d.ts:14
     1  node_modules/vitrea-client/dist/core/BaseRequest.d.ts:5
     1  node_modules/vitrea-client/dist/core/BaseResponse.d.ts:4
     1  node_modules/vitrea-client/dist/core/DataGram.d.ts:28
     2  node_modules/vitrea-client/dist/socket/AbstractHeartbeatHandler.d.ts:4
     5  node_modules/vitrea-client/dist/socket/AbstractSocket.d.ts:1
     1  node_modules/vitrea-client/dist/socket/WritableSocketContract.d.ts:2