Reputation: 4329
When starting my program, I get:
Error: Plugin routes-api-cruises missing dependency @hapi/nes
at new module.exports (/usr/src/app/node_modules/@hapi/hoek/lib/error.js:23:19)
at Object.module.exports [as assert] (/usr/src/app/node_modules/@hapi/hoek/lib/assert.js:20:11)
at module.exports.internals.Core._validateDeps (/usr/src/app/node_modules/@hapi/hapi/lib/core.js:348:22)
at module.exports.internals.Core._initialize (/usr/src/app/node_modules/@hapi/hapi/lib/core.js:320:14)
at module.exports.internals.Core._start (/usr/src/app/node_modules/@hapi/hapi/lib/core.js:240:24)
at internals.Server.start (/usr/src/app/node_modules/@hapi/hapi/lib/server.js:523:27)
at startServer (/usr/src/app/server.js:12:21)
at processTicksAndRejections (internal/process/task_queues.js:85:5)
I don't know whether "Plugin x missing dependency y" means the plugin fails to declare the dependency it uses, or whether the declared dependency is not installed.
It looks like the plugin declares its dependency:
exports.plugin = {
name: 'routes-api-cruises',
dependencies: ['hapi-mongodb', '@hapi/nes'], // <- there it is
...
}
It also looks like the package is installed:
$ find node_modules -iname 'nes'
node_modules/@hapi/nes
And package.json
includes:
"dependencies": {
"@hapi/nes": "^11.2.1",
...
}
And package-lock.json
includes:
@hapi/nes": {
"version": "11.2.2",
"resolved": "https://registry.npmjs.org/@hapi/nes/-/nes-11.2.2.tgz",
"integrity": "sha512-XGFfTQsBB7NnpIgVdnz36lrZjJlUgni0tLmcN4TWiYdCGxNr6+YRreQ6jdsGN3j8qfZ8yLBY0FsGkHBiMPKLAw==",
...
}
The code uses @hapi/glue
's compose()
function and passes in a list of plugins to register and @hapi/nes
is present.
Upvotes: 1
Views: 1030
Reputation: 4329
I found the source of that error in the Hapi source code and used the Node inspector to attach a breakpoint there.
The function _validateDeps
enumerates the dependencies declared by each plugin. It looks these up in this.registrations
, a map of plugin registrations.
In this.registrations
, @hapi/nes
shows up as simply nes
. Changing the plugin dependency declaration to simply nes
makes the lookup work.
Upvotes: 1