Skip to content

Tag: node.js

chain promises in javascript

I’ve created many promises like that, in order to create object in my database. At the end, I want call all my promises in the order I want. (because somes object depend of other, so I need to keep that order) So I expect to see : Unfortunately, this messages are shuffled and I don’t understand wh…

Express.Static not working for subdirectory

Express.static is working great for any view in root directory, but it breaks when I add a subdirectory. Works: Doesn’t Work: I’m guessing __dirname is changed to whatever directory the get request is made from, but I just want to use the root (/public) directory for all static requests. Answer Us…

How to use XHR API in Node.js?

This is a follow-up to my previous question Suppose I’ve some javascript code, which runs fine on client (in a browser). This code makes a lot of XHR calls using the browser API. Now I would like to run this code in node.js. Does node.js provide the XHR API as in browser ? Answer Natively Node.js does n…

Running npm globally installed packages

Can someone please explain how do node’s globally installed behave. It is really confusing me. If I install a package (with executables) such as http-serverglobally I can run it with: But if I do I get I suspect my ternpackage in emacs is trying to run it with node hence breaking. Why is this happening?…