【发布时间】:2020-04-08 03:40:19
【问题描述】:
启动我的程序时,我得到:
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)
我不知道“插件x缺少依赖y”是否意味着插件未能声明它使用的依赖,或者是否声明的依赖没有安装。
看起来插件声明了它的依赖:
exports.plugin = {
name: 'routes-api-cruises',
dependencies: ['hapi-mongodb', '@hapi/nes'], // <- there it is
...
}
好像也安装了包:
$ find node_modules -iname 'nes'
node_modules/@hapi/nes
而package.json 包括:
"dependencies": {
"@hapi/nes": "^11.2.1",
...
}
而package-lock.json 包括:
@hapi/nes": {
"version": "11.2.2",
"resolved": "https://registry.npmjs.org/@hapi/nes/-/nes-11.2.2.tgz",
"integrity": "sha512-XGFfTQsBB7NnpIgVdnz36lrZjJlUgni0tLmcN4TWiYdCGxNr6+YRreQ6jdsGN3j8qfZ8yLBY0FsGkHBiMPKLAw==",
...
}
代码使用@hapi/glue 的compose() 函数并传入要注册的插件列表,并且存在@hapi/nes。
【问题讨论】: