ioBroker.javascript
ioBroker.javascript copied to clipboard
Incorrect error "cannot find module" within the JavaScript Editor (IDE) when using a specific JavaScript Library
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
- Install a JavaScript Library, for example serialport
npm install serialport
- Add the name of the module 'serialport' within the instance settings of the javascript instance
- Create a new script an declare the rquires module
const { SerialPort } = require('serialport')
- 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
Incorrect red wavy line
Versions:
- Adapter version: 6.0.0
- JS-Controller version: 4.0.23
- Node version: 14.20.0
- Operating system: Linux
@AlCalzone ? Could that be also Typescript 4.8 issue?
Please try latest Javascript 6.0.2
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.
Ok doesn't look like this is happening anymore, not even on 6.0.3.
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.
That's a usage error though. The serial port you're using is locked by something else.
That what we suspected as well but installing it additional made https://github.com/oberstel/ioBroker.js-rotelControl/blob/main/rotel Control to work