I have express.js with ejs templating.
I can see that for first request, debugger stops at break point.
But after ejs serves page on browser, any further requests never stops at break point.
I tried lot of things in frustation -> webstorm, eclipse, node-inspector,etc
Is there some config for ejs or experss that I am missing?
Even console.log is not printing anything. I know flow works for sure.
Actually it was my bad.
I was trying to debug js in public folder which is client side js.
So i have debug using chrome developer tools instead of server side debugging.
Related
I have created an Express REST API and followed various methods to put debugger inside API callback function, but no luck. I also tried This link. Still I am not able to use debugger on API call. Any help would be appreciated.
Normally all you need to do to get such breakpoints hit is starting your Node.js run configuration in debugger and then opening <yourserver URL>/list in browser:
I'm beginner web-developer, front-end only. Sometimes i need to make existing working websites to be responsive. I use browser extension(Styler for Chrome), that show me window where i can insert my styles, which will be applied for a page. But it looks little difficult(need to write code in my text-editor, copy this to extension form, than again, again and again...). Is there a way, to integrate my local stylesheet, to existing website, make changes only in my editor and reload page automatically, like with local page? I've found something on LiveReload website -
http://feedback.livereload.com/knowledgebase/articles/86220-preview-css-changes-against-a-live-site-then-uplo, but I can't use their app, cause i'm on windows(LiveReload is still in beta on it). If anybody use similar, can you please explain how to get it to work? Thanks.
In process of expiriencing I found simple solution for this:
Need to install Chrome extension(CSS Inject).
Run web-server on your machine which will host your css file for injecting(CSS Inject works only with HTTP) and insert it to CSS Inject, in my situation it looks like - http:// adapt/css/style.css
Need livereload server. I'am using node.js and this package https://www.npmjs.com/package/livereload for this.
Create file in your web-site root(for example server.js)
Paste this code in server.js:
var livereload = require('livereload'),
server = livereload.createServer();
server.watch(__dirname + "/css");
console.log('waiting for changes');
Go to your live website and activate CSS Inject.
run node ./server.js
That's it. You can now modify your styles localy and see changes on real website.
If anybody knows better solution(using API from this package https://www.npmjs.com/package/livereload#api-options, specifically overrideURL option) or have better expirience with node.js and understang how to implemet it, please post your solution here, I will be grateful.
I'm building a web application using node.js, this is my first time working with node. I'm using express framework and I have a question about client side rendering.
All the tutorials that I have found online talk about express and server side rendering. They talk about how you can use jade the express templating engine, to serve rendered templates as reponse to your web application.
My application is going to be client heavy and most of the rendering will be done client side. I want to call server to just get plain JSON response and then render it client side, so server side rendering is not of much use.
In this case, is express a right choice? I really like the way I can write APIS in express but I'm concerned about how to serve my application. If I don't want to use the server side rendering it would mean that I would have to serve static HTML at the first call which seems weird to me.
You might want to try Emberjs if you want most of the work done on the client side. But still, you need to send the data to the client so one way is to build your app totally on the client side just by sending a plain html and working your way up there. You can also precompile jade
What you are describing sounds like you are searching for an javascript MVC(or other) solution.
There are a lot of possibilities. Take the right tools for the right job.
Try the following link to get an nice overview of what is possible.
Helping you select an MV* framework
The Heroku app i'm trying to get to work (code here):
https://github.com/heroku/facebook-template-nodejs
"Unsafe Javascript attempt to access frame with URL" errors occur when the page is loaded in chrome.
The login button takes you to facebook but does not actually log you into the app and gives the same errors.
Has anyone got this app to work on Chrome or can anyone advise as to how to patch it up?
P.S. it seems to work fine on Mozilla.
Almost certain this is a cross domain policy issue, as stated above. Generally speaking, you just need to add the correct header info to the response.
Access-Control-Allow-Origin: *
In Node, I think it is just a matter of adding it as another header in the response, using
response.writeHead
See http://nodejs.org/api/http.html#http_response_writehead_statuscode_reasonphrase_headers
Oh, and there's explicit instructions on how to do it if you're using Express. I see no reason why it can't work using plain old node then.
http://enable-cors.org/server_expressjs.html
So I looked at your link, in your case I think you just have to enter the header info prior to using any other express app methods.
As to why it works in Firefox and not Chrome, not sure. Both support CORS many versions back. Maybe you have some Chrome extension that's interfering.
I´ve tried socket.io to create a tiny chat. But now, I´m tring to do the same thing without any dependencies.
My server side seems to be OK, the problem is to render my html page when the browser doesn´t recognize any node.js code, e.g: "require" statement.
The following exception ir raised: Uncaught ReferenceError: require is not defined
I put <script src="chat2.js" type="text/javascript" charset="UTF-8"></script> on my page where "chat2.js" is my server implementation.
I´m rendering the page when I type "localhost:8080" on the webbrowser. I have no idea to makes page recognize the server side code written in the page.
Thanks!
node.js is a server side language. It's designed to run on the server powered by node. What makes this an interesting case is that the server-side language and the client-side language are both JavaScript. In some cases, the same code used on the server-side can also be used on the client side.
For instance, DOM manipulations are examples of actions that can be performed on the server-side, with a document that hasn't been sent to the client, and they're also examples of manipulations that are mostly done on the client-side.
However, you're trying to run code in the browser that can only run on the server. If the code contains modules that have dependencies on the server, then running it in the client is just not possible.