채택완료

node.js오류 다시 올립니다 ㅜㅜ 이미지깨짐으로인해

여기다 질문해도 되는지 모르겠지만.. 그래도 여기는 유능한 분들이 많아서.. 올려 보겠습니다.

 

 

0b226c8d5ee356a631f68b5cefb494d3_1449723116_1391.png

이런 오류가 나오네요..
대충 파일을 읽을수 없다는거 같은데.. 파일 명은 config.json 과 config_local.json-dist 입니다.. config_local.json-dist같은경우 config_local.json로 변경후 해봐도 그대로네요 ㅜㅜ 
참고로 설치 중인 건broswer quset 라는 게임입니다. 모듈 설치를 따로 또해야되는게 있는건지 아니면
다른 설정을 해야되는건지.. 알려주세요


참고로 main.js 소스는 밑 참고 해주세요

Copy
var fs = require('fs');var Metrics = require('./metrics');var ProductionConfig = require('./productionconfig');var _ = require('underscore');function main(config) {    var Log = require('log');    switch(config.debug_level) {        case "error":            log = new Log(Log.ERROR); break;        case "debug":            log = new Log(Log.DEBUG); break;        case "info":            log = new Log(Log.INFO); break;    };    var production_config = new ProductionConfig(config);    if(production_config.inProduction()) {        _.extend(config, production_config.getProductionSettings());    }    var ws = require("./ws");    var WorldServer = require("./worldserver");    var server = new ws.WebsocketServer(config.port, config.use_one_port, config.ip);    var metrics = config.metrics_enabled ? new Metrics(config) : null;    var worlds = [];    var lastTotalPlayers = 0;    var DatabaseSelector = require("./databaseselector");    var checkPopulationInterval = setInterval(function() {        if(metrics && metrics.isReady) {            metrics.updateWorldCount();            metrics.getTotalPlayers(function(totalPlayers) {                if(totalPlayers !== lastTotalPlayers) {                    lastTotalPlayers = totalPlayers;                    _.each(worlds, function(world) {                        world.updatePopulation(totalPlayers);                    });                }            });        }    }, 1000);    log.info("Starting BrowserQuest game server...");    var selector = DatabaseSelector(config);    databaseHandler = new selector(config);    server.onConnect(function(connection) {        var world; // the one in which the player will be spawned        var connect = function() {                if(world) {                    world.connect_callback(new Player(connection, world, databaseHandler));                }            };        if(metrics) {            metrics.getOpenWorldCount(function(open_world_count) {                // choose the least populated world among open worlds                world = _.min(_.first(worlds, open_world_count), function(w) { return w.playerCount; });                connect();            });        }        else {            // simply fill each world sequentially until they are full            world = _.find(worlds, function(world) {                return world.playerCount < config.nb_players_per_world;            });            world.updatePopulation();            connect();        }    });    server.onError(function() {        log.error(Array.prototype.join.call(arguments, ", "));    });    var onPopulationChange = function() {        metrics.updatePlayerCounters(worlds, function(totalPlayers) {            _.each(worlds, function(world) {                world.updatePopulation(totalPlayers);            });        });        metrics.updateWorldDistribution(getWorldDistribution(worlds));    };    _.each(_.range(config.nb_worlds), function(i) {        var world = new WorldServer('world'+ (i+1), config.nb_players_per_world, server, databaseHandler);        world.run(config.map_filepath);        worlds.push(world);        if(metrics) {            world.onPlayerAdded(onPopulationChange);            world.onPlayerRemoved(onPopulationChange);        }    });    server.onRequestStatus(function() {        return JSON.stringify(getWorldDistribution(worlds));    });    if(config.metrics_enabled) {        metrics.ready(function() {            onPopulationChange(); // initialize all counters to 0 when the server starts        });    }    process.on('uncaughtException', function (e) {        // Display the full error stack, to aid debugging        log.error('uncaughtException: ' + e.stack);    });}function getWorldDistribution(worlds) {    var distribution = [];    _.each(worlds, function(world) {        distribution.push(world.playerCount);    });    return distribution;}function getConfigFile(path, callback) {    fs.readFile(path, 'utf8', function(err, json_string) {        if(err) {            console.info("This server can be customized by creating a configuration file named: " + err.path);            callback(null);        } else {            callback(JSON.parse(json_string));        }    });}var defaultConfigPath = './server/config.json';var customConfigPath = './server/config_local.json';process.argv.forEach(function (val, index, array) {    if(index === 2) {        customConfigPath = val;    }});getConfigFile(defaultConfigPath, function(defaultConfig) {    getConfigFile(customConfigPath, function(localConfig) {        if(localConfig) {            main(localConfig);        } else if(defaultConfig) {            main(defaultConfig);        } else {            console.error("Server cannot start without any configuration file.");            process.exit(1);        }    });});
|

답변 9개 / 댓글 8개

채택된 답변
+20 포인트

npm install or update라고 치는 것이 아니고..

 

npm install 해보시던지..

 

아니면 npm update 둘중에 하나만 하라는 이야기입니다.

 

노드 책을 보시고 시작하라고 권하고 싶네요..

답변에 대한 댓글 2개

해보았죠;;
근데 안되서;; npm install or update 까지도 처보았습니다 ㅜㅜ
아 제가 멍청했네요 ㅜㅜ 구문 오류라고 뻔히 나오는데;; 확인도 안하고 질문부터 해버렸네요;;
그 node.js bcrypt 모듈이 없는데. 어디서 구해야 될까요;; npm으로 설치하면 에러가 떠서;;

npm install bcrypt 하시면 되고요..

 

없다고 하는 모듈은 대부분 위와 같은 형식으로 설치하시면 됩니다.

 

대부분의 연관된 파일은 packages.json에 들어가 있습니다. (없다면 여기다 추가)

답변에 대한 댓글 1개

bcrypt는 node-bcrypt로 변경해서 설치했구 다른 자바스크립트 파일들도 수정했구요 근데 다른 오류가 생기네요 ㅜㅜ

74903bde6de9fff919f5409208dae59f_1449799450_2976.png

 

이렇게 나오네요;;74903bde6de9fff919f5409208dae59f_1449799521_9742.png
그리고 마지막 혹시몰라 node server/js/main.js 실행까지 해봤지만.. 이렇게 나와요 ㅜㅜ
 

모든 파일이 d 디렉토리 밑에 있네요..

 

cd /users/pc/d

npm install or npm update 하시고

node server 해보세요

 

답변에 대한 댓글 1개

다시 사진으로 올렸습니다 ㅜㅜ 거의다 되는듯 싶은데.. 모듈 문제일까요?

74903bde6de9fff919f5409208dae59f_1449796696_6513.png

 

참고로 말씀드리면 http://uwooto.blogspot.kr/2014/09/nodejs-broswer-quest-windows.html

여기나와 있는 설치법대로 하였으며 틀리게 한부분이 있다면

 log bison websocket websocket-server sanitizer memcache  이모듈들은 설치가 안되있습니다.

underscore 이것만 설치 했고 다른건 설치오류가 나와 설치하지 못했습니다.


 

 

그냥 node server 로 하면 동작될 것 같은데요..

답변에 대한 댓글 1개

ㅜㅜ 이렇게 대버리네요 ㅜㅜ 사진은 다시 답변으로 올렸어요

74903bde6de9fff919f5409208dae59f_1449794111_3502.png
74903bde6de9fff919f5409208dae59f_1449793769_4333.png
C:\Users\PC\d 안에 다있어요 server 디렉토리 안에도 파일은 두개다 있구요

모든 파일이 user/pc 디렉토리 아래에 있나요?

 

c:/user/pc>dir

[server]

...

 

식으로..

 

답변에 대한 댓글 2개

C:\Users\PC\d 이 디렉토리 아래에 전부 들어있습니다.
질문 답변 댓글로 사진 올려뒀습니다..

메시지가 

configuration file없이는 실행할수가 없다고 하니..

 

 

var defaultConfigPath = './server/config.json';

var customConfigPath = './server/config_local.json';

 

 

2가지 파일이 있는지 체크 해보세요..

 

path는 풀 path 보다는 그냥 모든 파일이 있는 곳에서 실행하는 것으로 해보세요..

 

node js/main.js 식으로..

 

현디렉토리안에 모든 구성이 있어야 겠죠..

 

물론 server 디렉토리안에 위의 json파일 2개가 있어야 겠죠..

 

 

답변에 대한 댓글 1개

var defaultConfigPath = './server/config.json';

var customConfigPath = './server/config_local.json';

위 두가지 파일은 server디렉토리안에 다 있습니다..
있는데도 안되네요 ㅜㅜ

답변을 작성하려면 로그인이 필요합니다.