Can I pass variable to required file?

In express, I’m trying to move my minification to a requierd file: app.js: var app = express(); var minify = require(“./minify.js”); In that file I try to set my template engine. minify.js: var app = express(); app.engine(‘html’, mustacheExpress()); Later when I try to use to use the rendering engine in app.js, I get the error […]

Mocha's glob behaviour

This question already has an answer here: Mocha only running one test file 1 answer

Argument error, options.body in node.js?

what is the problem i don’t know please help to solve this. when i post data then below error shows on terminal. Attach is the code also. Error: Argument error, options.body. at Request.init (/usr/lib/nodejs/request/index.js:351:13) at new Request (/usr/lib/nodejs/request/index.js:124:8) at Object.request (/usr/lib/nodejs/request/index.js:1279:11) at Request._callback (/var/www/html/nodeproject/helloworld/controllers/login.js:68:11) at Request.self.callback (/usr/lib/nodejs/request/index.js:148:22) at Request.EventEmitter.emit (events.js:98:17) at Request.<anonymous> (/usr/lib/nodejs/request/index.js:896:14) at Request.EventEmitter.emit […]

Set cache header in hapi

How can I set the cache-control header in hapi to ‘no-cache’, ‘no-store’, ‘must-revalidate’? In express I am able to do the following: res.header(‘Cache-Control’, ‘no-cache, no-store, must-revalidate’); I currently have the following in hapi but I think it may be incorrect: function(request, reply){ var response = reply(); response.header(‘Cache-Control’, ‘no-cache’); response.header(‘Cache-Control’, ‘no-store’); response.header(‘Cache-Control’, ‘must-revalidate’ } Is it […]

Express handling URIError: Failed to decode param

var express = require(‘express’); var app = express(); app.get(‘*’, function (req, res) { var host = req.get(‘Host’); return res.redirect([‘https://’, host, req.url].join(”)); }); var server = app.listen(8080, function () { console.log(‘starting’); }); I have a simple script that redirects http to https. This is working fine except when there is a malformed url for example: website.com/%c0%ae%c0%ae. […]

Strongloop/Loopback – Get Started – Service manager failed to start

I followed the instructions for creating a standard project for Strongloop with IBM API Connect. Link to the tutorial At the “Start your API” step, when clicking on the start button, the API didn’t start. In my console, there was this error message: Unhandled rejection Error: Service manager failed to start. Please review /Users/edouardm/.apiconnect/strong-pm/start.log for […]

Node.js & npm: How can I create custom npm cli commands?

Say for example that I quite often use npm list -g -depth 0 as command, and I’d like to alias it with npm listC or npm list -c1. How do I do that?

Windows Error : Source Path Too Long

Explanation : There are about 15 subfolders in the node_modules directory.When going to perform any operation(deleted, moved or renamed) it popup below message. Error message: The source file name(s) are larger than is supported by the file system. Try moving to a location which has a shorter path name, or try renaming to shorter name(s) […]

Mongoose duplicate key error with upsert

I have problem with duplicate key. Long time can`t find answer. Please help me solve this problem or explain why i get duplicate key error. Trace: { [MongoError: E11000 duplicate key error collection: project.monitor index: _id_ dup key: { : 24392490 }] name: ‘MongoError’, message: ‘E11000 duplicate key error collection: project.monitor index: _id_ dup key: […]

Run node script from within a node script

I would like to use node-schedule to run a certain node script at a certain time. Can I do something like this in node.js? var schedule = require(‘node-schedule’); //https://www.npmjs.com/package/node-schedule var j = schedule.scheduleJob(’00 00 22 * * *’, function () { console.log(‘Running XX node.js script …’); NodeShell.run(__dirname + ‘\\XX.js’, function (err) { if (err) throw […]

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