plouc / mozaik-demo

Sample mozaïk app with two dashboards
http://mozaik.rocks/
103 stars 75 forks source link

Server fails to start [v2] #17

Open juhamust opened 6 years ago

juhamust commented 6 years ago
item info notes
node version v8.9.0
npm version 5.5.1
mozaik-demo version #61504051511
@mozaik/server version 2.0.0-alpha.7

Expected behavior

Server should start without errors, as documented in http://mozaik.rocks/v2/use/

Actual behavior

For some reason, instance methods are not found:

> using config file: 'conf/config.yml'

/Users/juha/mozaik-demo/server.js:10
Mozaik.configureFromFile(path.join(__dirname, configFile))
       ^

TypeError: Mozaik.configureFromFile is not a function
    at Object.<anonymous> (/Users/juha/mozaik-demo/server.js:10:8)
    at Module._compile (module.js:635:30)
    at Object.Module._extensions..js (module.js:646:10)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)
    at Function.Module.runMain (module.js:676:10)
    at startup (bootstrap_node.js:187:16)
    at bootstrap_node.js:608:3

Steps to reproduce

git clone https://github.com/plouc/mozaik-demo.git
cd mozaik-demo
git checkout mozaik-2
npm install
node server.js
jderusse commented 6 years ago

Fixed it with


// server.js
-const Mozaik = require('@mozaik/server')                                                                                                                     
+const Mozaik = require('@mozaik/server').default           
plouc commented 6 years ago

@jderusse, thank you

dogoepp commented 5 years ago

From the latest commit of the v2 branch, I actually have to remove .default to get it to work.

I'm not yet familiar with JS nor Mozaïk so I couldn't understand the reason behind this observation.

chakibus commented 5 years ago

From the latest commit of the v2 branch, I actually have to remove .default to get it to work.

I'm not yet familiar with JS nor Mozaïk so I couldn't understand the reason behind this observation.

Me too I had to remove the .default to get it to work otherwise I was facing bellow error:

Server.configureFromFile(path.join(__dirname, configFile)) ^

TypeError: Cannot read property 'configureFromFile' of undefined at Object. (/Users/cmelaika/Projects/dashboard/server.js:10:8) at Module._compile (module.js:653:30) at Object.Module._extensions..js (module.js:664:10) at Module.load (module.js:566:32) at tryModuleLoad (module.js:506:12) at Function.Module._load (module.js:498:3) at Function.Module.runMain (module.js:694:10) at startup (bootstrap_node.js:204:16) at bootstrap_node.js:625:3