ioBroker.javascript icon indicating copy to clipboard operation
ioBroker.javascript copied to clipboard

Incorrect error "cannot find module" within the JavaScript Editor (IDE) when using a specific JavaScript Library

Open oberstel opened this issue 2 years ago • 6 comments

Describe the bug
While a JavaScript Library (for example serialport) is installed correctly and defined in the list of additional NPM modules, the Editor reports an error when using such a library.

The name of the library (in my example serialport) is reported as unknown: Cannot find module 'serialport' or its corresponding type declarations.(2307)

However, the library with all it's functions is working very well.

To Reproduce

  1. Install a JavaScript Library, for example serialport npm install serialport
  2. Add the name of the module 'serialport' within the instance settings of the javascript instance
  3. Create a new script an declare the rquires module const { SerialPort } = require('serialport')
  4. The name of the module serialport will be idicated as a problem with a red wavy line (see screenshot)

Expected behavior
The name of the module should not be reported as a problem or an error

Screenshots & Logfiles
Screenshot 2022-09-18 12 56 57 Incorrect red wavy line

Versions:

  • Adapter version: 6.0.0
  • JS-Controller version: 4.0.23
  • Node version: 14.20.0
  • Operating system: Linux

oberstel avatar Sep 18 '22 10:09 oberstel

@AlCalzone ? Could that be also Typescript 4.8 issue?

Please try latest Javascript 6.0.2

Apollon77 avatar Sep 18 '22 14:09 Apollon77

First off:

npm install serialport

why do this manually? The adapter takes care of this.

Second: The adapter has a field in the settings to enable syntax help for modules, but serialport needs to be added there manually. If not, the adapter should generate dummy type definitions to prevent the above error. I'll check if this is still working.

AlCalzone avatar Sep 19 '22 08:09 AlCalzone

Ok doesn't look like this is happening anymore, not even on 6.0.3.

AlCalzone avatar Sep 19 '22 09:09 AlCalzone

it is still happening in

Release Stable Release v7.2.0 · buanet/ioBroker.docker admin: v6.3.5 NPM: 8.19.3 js-controller: 4.0.24 Node.js: v16.19.1

In addition, it those not throw a clear error if only

root@iobroker:/opt/iobroker# npm ls serialport 
[email protected] /opt/iobroker
├─┬ [email protected]
│ └── [email protected]

is given instead of

root@iobroker:/opt/iobroker# npm ls serialport
[email protected] /opt/iobroker
├─┬ [email protected]
│ └── [email protected]
└─┬ [email protected]
  └── [email protected]

I get only such mysterious message:

javascript.0 2023-03-21 10:59:42.953 error Error: Error Resource temporarily unavailable Cannot lock port javascript.0 2023-03-21 10:59:42.948 error Error: Error Resource temporarily unavailable Cannot lock port javascript.0 2023-03-21 10:59:42.947 error An error happened which is most likely from one of your scripts, but the originating script could not be detected.

PackElend avatar Mar 21 '23 17:03 PackElend

That's a usage error though. The serial port you're using is locked by something else.

AlCalzone avatar Mar 21 '23 18:03 AlCalzone

That what we suspected as well but installing it additional made https://github.com/oberstel/ioBroker.js-rotelControl/blob/main/rotel Control to work

PackElend avatar Mar 21 '23 18:03 PackElend