server.views undefined is not a function
Closed this issue · 5 comments
When I register plugin with server.register(Tv, callback)
I get this
C:\projects\test\node_modules\Tv\lib\index.js:31
server.views({
^
TypeError: undefined is not a function
at Object.exports.register (C:\projects\test\node_modules\Tv\lib\index.js:31:12)
at Items.serial.self.root._registring (C:\projects\test\node_modules\hapi\lib\plugin.js:255:14)
at iterate (C:\projects\test\node_modules\hapi\node_modules\items\lib\index.js:35:13)
at Object.exports.serial (C:\projects\test\node_modules\hapi\node_modules\items\lib\index.js:38:9)
at internals.Plugin.register (C:\projects\test\node_modules\hapi\lib\plugin.js:234:11)
at HapiApi.attachPlugins (C:\projects\test\modules\api\HapiApi.js:59:19)
at HapiApi.init (C:\projects\test\modules\api\HapiApi.js:43:10)
at C:\projects\test\app.js:31:11
at Function.Injector.applyMap (C:\dev\projects\node-autowire\lib\Injector.js:191:20)
at Function.func.(anonymous function) (C:\dev\projects\node-autowire\lib\Functionize.js:59:28)
at Function.Injector.exec (C:\dev\projects\node-autowire\lib\Injector.js:150:15)
at Function.func.(anonymous function) (C:\dev\projects\node-autowire\lib\Functionize.js:59:28)
at Function.<anonymous> (C:\dev\projects\node-autowire\index.js:131:21)
at f (C:\dev\projects\node-autowire\lib\Functionize.js:92:15)
at Object.<anonymous> (C:\projects\test\app.js:26:1)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3
Probable cause: hapijs/hapi#2706 i.e. hapi 9 compatibility problem.
It worked after registering inert
and vision
plugin manually i.e. server.register([require('inert'), require('vision'), require('tv'), function(err) {...}); // in that order
I'm running into the same error, but it does not work when registering inert
and vision
. However, I'm using Glue, so maybe that's the reason why.
I updated Hapi to 11.x and get the same problem in my test code (i use composer manifest for develop code). Then I move the server.views to the register callback, the issue is solved :). Hope it help
Show my code (it a test case code, but in the develop code, the register, and config server view is same)
Hi, I'm new to hapi. Facing same issue "server.views undefined is not a function" Anyone knows how to fix this issue?