Purpose of installing Twitter Bootstrap through npm?

If you NPM those modules you can serve them using static redirect. First install the packages: npm install jquery npm install bootstrap Then on the server.js: var express = require(‘express’); var app = express(); // prepare server app.use(‘/api’, api); // redirect API calls app.use(“https://stackoverflow.com/”, express.static(__dirname + ‘/www’)); // redirect root app.use(‘/js’, express.static(__dirname + ‘/node_modules/bootstrap/dist/js’)); // … Read more

Exec : display stdout “live”

Don’t use exec. Use spawn which is an EventEmmiter object. Then you can listen to stdout/stderr events (spawn.stdout.on(‘data’,callback..)) as they happen. From NodeJS documentation: var spawn = require(‘child_process’).spawn, ls = spawn(‘ls’, [‘-lh’, ‘/usr’]); ls.stdout.on(‘data’, function (data) { console.log(‘stdout: ‘ + data.toString()); }); ls.stderr.on(‘data’, function (data) { console.log(‘stderr: ‘ + data.toString()); }); ls.on(‘exit’, function (code) { … Read more

can you host a private repository for your organization to use with npm?

https://github.com/isaacs/npmjs.org/ : In npm version v1.0.26 you can specify private git repositories urls as a dependency in your package.json files. I have not used it but would love feedback. Here is what you need to do: { “name”: “my-app”, “dependencies”: { “private-repo”: “git+ssh://git@yourgitserver.com:my-app.git#v0.0.1”, } } The following post talks about this: Debuggable: Private npm modules

How to get all registered routes in Express?

express 3.x Okay, found it myself … it’s just app.routes 🙂 express 4.x Applications – built with express() app._router.stack Routers – built with express.Router() router.stack Note: The stack includes the middleware functions too, it should be filtered to get the “routes” only.

What is the difference between res.end() and res.send()?

I would like to make a little bit more emphasis on some key differences between res.end() & res.send() with respect to response headers and why they are important. 1. res.send() will check the structure of your output and set header information accordingly. app.get(“https://stackoverflow.com/”,(req,res)=>{ res.send(‘<b>hello</b>’); }); app.get(“https://stackoverflow.com/”,(req,res)=>{ res.send({msg:’hello’}); }); Where with res.end() you can only respond … Read more

How to read from stdin line by line in Node

You can use the readline module to read from stdin line by line: const readline = require(‘readline’); const rl = readline.createInterface({ input: process.stdin, output: process.stdout, terminal: false }); rl.on(‘line’, (line) => { console.log(line); }); rl.once(‘close’, () => { // end of input });

The engine “node” is incompatible with this module

You can try to ignore the engines : $ yarn install –ignore-engines OR $ yarn global add <your app> –ignore-engines You can see all what you can ignore by running: $ yarn help | grep — –ignore –ignore-scripts don’t run lifecycle scripts –ignore-platform ignore platform checks –ignore-engines ignore engines check –ignore-optional ignore optional dependencies

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)