Closed nitinsh99 closed 5 years ago
Probably because you are passing the package.json of your application, not one created specifically for the plugin... Also, ...Pkg
has never been the way to pass package info to the plugin. There is a property for that.
Probably because you are passing the package.json of your application, not one created
No, please download and check the code I attached, plugin is consuming it's own package.json
Also,
...Pkg
has never been the way to pass package info to the plugin. There is a property for that.
That's just spread syntx.. eventually plugins exports something like this
module.exports = {
name : abc,
deps: ... <----- This is causing the issue...
devdeps: ....
version : x.x.x,
async register {
}
}
CC : @hueniverse
It's failing for the exact reasons @hueniverse already mentioned, because you're using spread and adding way too many unnecessary properties. Read the last paragraph of https://hapi.dev/api/#plugins and use that instead.
adding way too many unnecessary properties
got it working by using pkg
attribute.. not sure if it's worth mentioning in the docs that if using {name, version, async register} syntax NO additional
properties should be passed.. also error is very misleading..
When I use spread.. I am passing name, version, deps and additional stuff..
It makes sense because package.json and plugin attributes both share a dependencies
property, but it has different meanings in each context. The solution is to use the pkg
attribute as you've done.
Hi,
I am using hapi17. I created a simple hapi server and I am trying to register a plugin. In the register method of the plugin, if I supply whole package.json file then server throws an error while starting. For example:
Plugin
Server
Error
AssertionError: Plugin hapi-info missing dependency @hapi/joi
If I pass only name and version in the register method of the plugin, then issue is not there.
Full code with issue: https://drive.google.com/file/d/1HM2ooalDGHexLLt2ieCTCnPc2sCpJYzk/view?usp=sharing