Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Вопрос по 11 части (nodejs-screencast-chat) #3

Closed
Alex79 opened this issue Jun 3, 2014 · 5 comments
Closed

Вопрос по 11 части (nodejs-screencast-chat) #3

Alex79 opened this issue Jun 3, 2014 · 5 comments

Comments

@Alex79
Copy link

Alex79 commented Jun 3, 2014

Спасибо за ваш отличный скринкаст! Помогите разобраться с 11 уроком.

  1. запускаю app.js, захожу в чат набираю сообщение нажимаю Enter и Chome намертво зависает(Firefox тоже). Логгер никаких сообщений не выдает, кроме
    "C:\Program Files\nodejs\node.exe" app.js
    info: [C:\Chat\app.js] Express server listening on port 3000
    GET / 200 36ms - 942b
    GET /vendor/bower_components/bootstrap/dist/css/bootstrap.css 304 6ms
    GET /css/app.css 304 6ms
    GET /vendor/bower_components/jquery/jquery.js 304 6ms
    GET /vendor/bower_components/bootstrap/dist/js/bootstrap.js 304 6ms
    POST /logout 302 4ms - 58b
    GET / 200 99ms - 825b
    GET /vendor/bower_components/bootstrap/dist/css/bootstrap.css 304 3ms
    GET /css/app.css 304 2ms
    GET /vendor/bower_components/jquery/jquery.js 304 2ms
    GET /vendor/bower_components/bootstrap/dist/js/bootstrap.js 304 2ms
    GET /login 200 6ms - 2.48kb
    GET /vendor/bower_components/bootstrap/dist/css/bootstrap.css 304 5ms
    GET /css/app.css 304 5ms
    GET /vendor/bower_components/jquery/jquery.js 304 4ms
    GET /vendor/bower_components/bootstrap/dist/js/bootstrap.js 304 4ms
    POST /login 200 5ms - 2b
    GET /chat 304 4ms
    GET /vendor/bower_components/bootstrap/dist/css/bootstrap.css 304 7ms
    GET /css/app.css 304 9ms
    GET /vendor/bower_components/jquery/jquery.js 304 8ms
    GET /vendor/bower_components/bootstrap/dist/js/bootstrap.js 304 8ms
    Останавливаю сервер пишет Process finished with exit code -1
    Если в app.js закомментировать строку cb("123"); здесь:
    io.sockets.on('connection', function (socket) {

socket.on('message', function (text, cb) {
socket.broadcast.emit('message', text);
//cb("123");
});
}); То сообщения отправляются, подскажите в чем проблема?
2) Если файлы из папки template не копировать в корень диска c:\ то на станице логина появляется такая ошибка:
Express
500 Error: ENOENT, no such file or directory 'C:\layout\page.ejs'
Хотя в папке проекта они есть (в С:\Chat\template). и NODE_PATH=C:\Chat и NODE_ENV=development

@iliakan
Copy link
Owner

iliakan commented Jun 3, 2014

Видимо, нужно в исходнике поменять /page.js на page.js или наоборот, попробуй? Там винда как-то странно себя вела в путях.

@Alex79
Copy link
Author

Alex79 commented Jun 3, 2014

в login.ejs изменил <% layout('/layout/page') -%> на <% layout('C:\Chat\template\layout\page') -%>, спасибо, работает.
в арр.js под виндой не работает callback и socket.broadcast.emit('message', text); так "работает":
socket.emit('message', text);
//cb("123");
винда глючит?

@iliakan
Copy link
Owner

iliakan commented Jun 3, 2014

Попробуй просто layout/page, без первого слеша. Да, есть здесь различие.

@Alex79
Copy link
Author

Alex79 commented Jun 9, 2014

Да, так работает.
Подскажите как вывести всех Users из MongoDB без названия полей, т. е.
var User = require('models/user').User;
User.find({ }, { username: 1, _id:0}, function(err, tester){
console.log(tester);
});
Выводит:
[ { username: 'admin' },
{ username: 'name' }]
А нужно:
admin
name

@finico
Copy link

finico commented Jun 9, 2014

@Alex79

User.find({ }, { username: 1, _id:0}, function(err, tester){
  tester.forEach(function (user) {
    console.log(user.username);
  });  
});

@iliakan iliakan closed this as completed Oct 16, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants