Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I am trying to learn the theory of node.js but can't seem to figure out how node.js knows whether to pre process it on the server or send it to browser for execution.

share|improve this question
2  
node.js does not execute code client-side. It does not pre-process anything. node.js is a server-side platform only. –  Brandon Jul 31 '14 at 17:05

1 Answer 1

up vote 2 down vote accepted
  • node example.js runs the code server side.

  • require('./example.js') within the server-side JavaScript file also runs the code server side.

  • Serving a static file ending with ".js" to a client will make it a client-side JavaScript.

share|improve this answer
    
ok thanks for the help. I couldnt find that anywhere in documentation. –  8bitedge Jul 31 '14 at 16:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.