Upstart | Ubuntu | Nodejs | Can not run multiple exec inside script block

I’m trying to setup a upstart conf for my nodejs app. I have to run 2 script scrip_1.js and script_2.js. Here the conf start on startup stop on shutdown respawn console log env PROJ=/project/path script cd $PROJ exec node script_1.js 2>&1 >> $PROJ/logs/script_1.log exec node script_2.js 2>&1 >> $PROJ/logs/script_2.log end script The problem is only […]

nodejs – JSON.stringify Error object

I’m trying to convert Error object to JSON. However, the Error message seems to be lost. try{ require(‘someModule’); }catch(error){ console.log(JSON.stringify(error)) //{“code”:”MODULE_NOT_FOUND”} } Did I do anything wrong? How can I fix it?

JSON stringify in Node JS not serializing array of objects

I am using sails.js (node js framework). I am trying to JSON.stringify one of the objects, but when I do that it omits one of the fields (rooms array below). Here is what console.log(object) gives me: [ { rooms: [ [Object], [Object] ], state: ’53df76c278999310248072c6′, name: ‘Sydney Center’, menuItems: null, createdAt: Mon Aug 04 2014 […]

Error: Failed to lookup view

Iam getting following error if I try to open the localhost:3000 or localhost:3000/login. Can someone help me what is the problem? It is very strange. Many thanks My Code var express = require(‘express’); var crypto = require(‘crypto’); var bodyParser = require(‘body-parser’); var flash = require(‘connect-flash’); var cookieParser = require(‘cookie-parser’); var session = require(‘express-session’); var path […]

remove query in mongodb by _id with nodejs

removing a row in mongodb isn’t seem to be that easy as in SQL lol, well, my issue is that I cant remove a row by the _id because the _id contains an obj ObjectId, that’s the row in the db, { “_id” : ObjectId(“541ec60e41b46b841adde31e”), “name” : “TT” } and this is how I’m trying […]

ouput css file rather than inline

How to ouput css file as file.css rather than inline in javascript. My configuration look like below. { test: /\.less$/, loader: “style-loader!css-loader!less-loader” } I tested with “file-loader!css-loader!less-loader” //but the content of the file is not css

How do you export a variable from app.js into another route in Node js

i’m using in my node project and wanted to know how to possibly export the io variable this is what i have done so far but i get this error: Object #<Object> has no method ‘on’ in app.js: var express = require(‘express’); var path = require(‘path’); var favicon = require(‘serve-favicon’); var logger = require(‘morgan’); […]

npm debug module is not working

I need to use debug module to replace my console.log s in my node application. I install the debug module in my application using following command. npm install debug Then I initialize the debug variable I try to print some information like below. var debug = require(‘debug’)(‘http’); debug(‘debug information’); but nothing is displayed in the […]

module “require” inside a Jade file

I need to use “fs” module inside a Jade file. No other JS file. When I try: – var js = require(‘fs’) – var downloadfiles = readdirSync(“download”) for f in downloadfiles url loc= D + “/download” + f lastmod= buildDate changefreq daily priority 1.0 I got the error “undefined is not a function”

Mongoose – REST API – Schema With Query to different model

I’m trying to avoid DB Callback Queries. Assuming that you have two schemas that looks like so : 1st) User Schema username : {type: String, unique: true}, age : {type: Number} 2nd) Activity Schema owner: [{type: Schema.Types.ObjectId, ref: ‘User’}], city: {type: String}, date: {type: Date} So far so good. Now lets say you have a […]

Node.js is the Best Javascript runtime in the world.