With the most recent patch version 1.16.3, there appears to be a difference in the required dependencies (and compiled output) compared to the previous version 1.16.2 that causes module resolution issi
In v1.16.3, there are 3 additional folders in the dist output:
Requiring lodash.merge (called from dist/common-amqp/amqp.js) fails due to missing the azure-iot-amqp-base dependency which had been included with this lib.
Error: Cannot find module 'lodash.merge'
Require stack:
- /usr/src/app/node_modules/azure-iothub/dist/common-amqp/amqp.js
- /usr/src/app/node_modules/azure-iothub/dist/amqp.js
- /usr/src/app/node_modules/azure-iothub/dist/client.js
- /usr/src/app/node_modules/azure-iothub/iothub.js
- /usr/src/app/main.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1026:15)
at Function.Module._load (node:internal/modules/cjs/loader:871:27)
at Module.require (node:internal/modules/cjs/loader:1098:19)
at require (node:internal/modules/cjs/helpers:108:18)
at Object.<anonymous> (/usr/src/app/node_modules/azure-iothub/dist/common-amqp/amqp.js:16:15)
at Module._compile (node:internal/modules/cjs/loader:1196:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1250:10)
at Module.load (node:internal/modules/cjs/loader:1074:32)
at Function.Module._load (node:internal/modules/cjs/loader:909:12)
at Module.require (node:internal/modules/cjs/loader:1098:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/usr/src/app/node_modules/azure-iothub/dist/common-amqp/amqp.js',
'/usr/src/app/node_modules/azure-iothub/dist/amqp.js',
'/usr/src/app/node_modules/azure-iothub/dist/client.js',
'/usr/src/app/node_modules/azure-iothub/iothub.js',
]
Resolution
I was able to revert to v1.16.2 which does not experience this issue. My recommendation is to replace any lodash direct npm package calls (e.g. lodash.merge) with either named imports or submodules of the main lodash package (e.g. lodash/merge).
Context
With the most recent patch version 1.16.3, there appears to be a difference in the required dependencies (and compiled output) compared to the previous version 1.16.2 that causes module resolution issi
Discoveries
Dependencies Variation
See below differences in the package.json.
v1.16.2
v1.16.3
In v1.16.3, there are 3 additional folders in the dist output:
Requiring
lodash.merge
(called fromdist/common-amqp/amqp.js
) fails due to missing theazure-iot-amqp-base
dependency which had been included with this lib.Resolution
I was able to revert to v1.16.2 which does not experience this issue. My recommendation is to replace any lodash direct npm package calls (e.g.
lodash.merge
) with either named imports or submodules of the main lodash package (e.g.lodash/merge
).