"Manually" installing dependencies in a sub-package of our "install" project (/opt/iobroker/package.json) once worked fine, but increasingly collides with what npm does while managing the dependencies. We already stopped doing a separate npm install inside the adapter directories in #1339, but some adapters still do this, leading to weird issues.
I therefore propose we get rid of this too and do the installation in a central location, adding the dependencies to our root package.json. To avoid conflicts, we need to fake-namespace these packages, which npm supports using the npm: protocol. Npm supports this since 6.9.0 (npm/cli#3):
This has the downside that the adapters need to be able to redirect the require to the correct package name, e.g. javascript.0 would have to require @iobroker-javascript.0/axios instead of just axios, but we can expose a utility for this too.
The upside would be that versioning these dependencies would become a bit more manageable, and another adapter installing the same one would not accidentally cause a conflict. This way we can also support multiple instances of javascript have different versions of the same package, since the fake scopes are instance-specific. In addition, maybe the adapters wouldn't even have to store their dependencies separately anymore, but could rather enumerate them from the root package.json.
"Manually" installing dependencies in a sub-package of our "install" project (
/opt/iobroker/package.json) once worked fine, but increasingly collides with whatnpmdoes while managing the dependencies. We already stopped doing a separatenpm installinside the adapter directories in #1339, but some adapters still do this, leading to weird issues.I therefore propose we get rid of this too and do the installation in a central location, adding the dependencies to our root
package.json. To avoid conflicts, we need to fake-namespace these packages, which npm supports using thenpm:protocol. Npm supports this since6.9.0(npm/cli#3):This has the downside that the adapters need to be able to redirect the
requireto the correct package name, e.g.javascript.0would have to require@iobroker-javascript.0/axiosinstead of justaxios, but we can expose a utility for this too.The upside would be that versioning these dependencies would become a bit more manageable, and another adapter installing the same one would not accidentally cause a conflict. This way we can also support multiple instances of
javascripthave different versions of the same package, since the fake scopes are instance-specific. In addition, maybe the adapters wouldn't even have to store their dependencies separately anymore, but could rather enumerate them from the rootpackage.json.