eclipse-thingweb / node-wot

Components for building WoT devices or for interacting with them over various IoT protocols
https://thingweb.io
Other
158 stars 79 forks source link

Re-creating package-lock.json fails #1292

Open danielpeintner opened 3 weeks ago

danielpeintner commented 3 weeks ago

While working on https://github.com/eclipse-thingweb/node-wot/pull/1291 I tried to update all dependencies. Essentially I did the following:

  1. Delete package-lock.json file
  2. Delete any local cache (like node_modules folders etc.)
  3. Run npm install
  4. Run npm dedupe (see https://github.com/eclipse-thingweb/node-wot/pull/765#issuecomment-1133772886)

like mentioned in our README under "Development Internals"

So far so good, no issue. Anyhow, afterwards npm run build does not work and fails since some time. See below the error

> build
> tsc -b && npm run build -w packages/browser-bundle

node_modules/bl/node_modules/@types/readable-stream/index.d.ts:355:9 - error TS2416: Property 'pipe' in type 'Duplex' is not assignable to the same property in base type '_Writable'.
  Type '<S extends _IWritable>(dest: S, pipeOpts?: { end?: boolean | undefined; } | undefined) => S' is not assignable to type '<T extends WritableStream>(destination: T, options?: { end?: boolean | undefined; } | undefined) => T'.
    Types of parameters 'dest' and 'destination' are incompatible.
      Type 'T' is not assignable to type '_IWritable'.
        Type 'WritableStream' is not assignable to type '_IWritable'.
          The types returned by 'end(...)' are incompatible between these types.
            Type 'void' is not assignable to type '_IWritable'.

355         pipe<S extends _IWritable>(dest: S, pipeOpts?: { end?: boolean | undefined }): S;
            ~~~~

node_modules/mqtt/node_modules/@types/readable-stream/index.d.ts:355:9 - error TS2416: Property 'pipe' in type 'Duplex' is not assignable to the same property in base type '_Writable'.
  Type '<S extends _IWritable>(dest: S, pipeOpts?: { end?: boolean | undefined; } | undefined) => S' is not assignable to type '<T extends WritableStream>(destination: T, options?: { end?: boolean | undefined; } | undefined) => T'.
    Types of parameters 'dest' and 'destination' are incompatible.
      Type 'T' is not assignable to type '_IWritable'.
        Type 'WritableStream' is not assignable to type '_IWritable'.
          The types returned by 'end(...)' are incompatible between these types.
            Type 'void' is not assignable to type '_IWritable'.

355         pipe<S extends _IWritable>(dest: S, pipeOpts?: { end?: boolean | undefined }): S;
            ~~~~

packages/examples/src/bindings/coap/example-client.ts:17:35 - error TS2307: Cannot find module '@node-wot/binding-coap' or its corresponding type declarations.

17 import { CoapClientFactory } from "@node-wot/binding-coap";
                                     ~~~~~~~~~~~~~~~~~~~~~~~~

packages/examples/src/bindings/coap/example-server.ts:17:28 - error TS2307: Cannot find module '@node-wot/binding-coap' or its corresponding type declarations.

17 import { CoapServer } from "@node-wot/binding-coap";
                              ~~~~~~~~~~~~~~~~~~~~~~~~

packages/examples/src/quickstart/presence-sensor.ts:20:34 - error TS2307: Cannot find module '@node-wot/binding-mqtt' or its corresponding type declarations.

20 import { MqttBrokerServer } from "@node-wot/binding-mqtt";
                                    ~~~~~~~~~~~~~~~~~~~~~~~~

packages/examples/src/quickstart/smart-clock.ts:19:28 - error TS2307: Cannot find module '@node-wot/binding-coap' or its corresponding type declarations.

19 import { CoapServer } from "@node-wot/binding-coap";
                              ~~~~~~~~~~~~~~~~~~~~~~~~

Found 6 errors.
danielpeintner commented 3 weeks ago

The change in package-lock.json that seems to cause issues is the following

image

Not sure what we can do here!?

danielpeintner commented 3 weeks ago

See attached the package-lock.json file that gets generated. I noticed that there are varying versions for @types/readable-stream:

Could it be that there is a change between v2 and v4 that causes the issue/inconsistency?

node-wot itself (package.json wise) has it in root only (and twice as indirect dependency in COAP v2 and MQTT v4)

danielpeintner commented 3 weeks ago

node-wot itself (package.json wise) has it in root only (and twice as indirect dependency in COAP v2 and MQTT v4)

FYI: updating it to "^4.0.5" doesn't help. I think the issue is that CoAP still uses v2, see

https://github.com/coapjs/node-coap/blob/0ac5017e605b7ab06a703a9b28a5f582b3217b93/package.json#L58

@JKRhb do you know whether there is any plan to upgrade?

EDIT: @types/readable-stream in node-coap are v2 but readable-stream is v4. Could this be an issue? https://github.com/coapjs/node-coap/blob/0ac5017e605b7ab06a703a9b28a5f582b3217b93/package.json#L64C6-L64C21

JKRhb commented 2 days ago

I've just published a new version of node-coap with updated dependencies :) I hope that will contribute to resolving this issue.

danielpeintner commented 1 day ago

@JKRhb I updated the coap library but I still run into issues, see https://github.com/eclipse-thingweb/node-wot/pull/1297

JKRhb commented 1 day ago

Hmm, that is very strange :/ But this seems to also occur with other bindings, if I am not mistaken, as the error persists even after removing the CoAP binding from the workspace.

danielpeintner commented 1 day ago

True. I didn't try it before. It fails for me if I try to use td-tools only.

What I also noticed is that we refer to readable stream in td-tools ts.config.json file

https://github.com/eclipse-thingweb/node-wot/blob/96fe7c4991476609ac71159d37e20ad622139dea/packages/td-tools/tsconfig.json#L5

Does anyone know why we need it? Removing it causes issues with importing debug and ajv-formats ...