mozaik-demo icon indicating copy to clipboard operation
mozaik-demo copied to clipboard

Server fails to start [v2]

Open juhamust opened this issue 6 years ago • 4 comments

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

juhamust avatar Sep 06 '18 19:09 juhamust

Fixed it with

// server.js
-const Mozaik = require('@mozaik/server')                                                                                                                     
+const Mozaik = require('@mozaik/server').default           

jderusse avatar Sep 13 '18 13:09 jderusse

@jderusse, thank you

plouc avatar Sep 14 '18 04:09 plouc

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.

dogoepp avatar Jan 21 '19 15:01 dogoepp

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

chakibus avatar Jul 19 '19 14:07 chakibus