node js installation
==> what is node js?
node js is open source server side rendered javascript. node js runs on server so
we can write our server side code in same language. it is cross platform, cross
plat form means it can run on windows, mac etc (example of electron). it is also a
javascript. node js is built in c++.
officially: - Node.js is a platform built on Chrome's JavaScript runtime for easily
building fast and scalable network applications. Node.js uses an event-driven, non-
blocking I/O model that makes it lightweight and efficient, perfect for data-
intensive real-time applications that run across distributed devices.
==> features of node.js
1 ) Language re-use(server side) = Technologies like ASP.NET or Spring requires
developers to know yet another language to write code on the server-side; be it C#,
VB.NET, Java or any other. On the other hand, Node.js uses JavaScript both on the
server and client side, meaning that developers only have to talk in a single
language across all layers.
2) Easy developer transition = JavaScript is a common ground between web
developers, that�s a known fact. Most of us know JavaScript or have used it at some
point in time; of course, because of this, transitioning a web developer from any
other web technology to Node.js is easy as pie.
3) It is lightweight = Node.js uses an event-driven architecture which means
everything done on it, every single call and operation, is a chain of asynchronous
callbacks. This allows Node.js to run on a single thread, different to other web
technologies, which spawn a new thread per-client request. This is the very
foundation of the non-blocking I/O nature you may have heard that is Node.js� main
feature.
4)Built-in support for object databases = It is really common for Node.js
applications to use object databases such as MongoDB. MongoDB, contrary to
traditional SQL databases, it uses a document-based model instead of a relational
model; this means that instead of tables, it uses objects resembling JSON. Just the
right answer for ORM fans.
5)Wide support from IDEs and code editors = JavaScript has been around for a long
time, so code hinting and highlighting is featured by a bunch IDEs like Visual
Studio and Eclipse; also editors like Notepad++ and Sublime Text.
==> what is express js.
express js is web development framework.it is javascript package that allow us to
build a web application. it's fairly minimalist that's alllows to just get stuff
done.
==> installation of node.js
go to node.js web site, download setup for required os. and install it. to check ,
type in cmd 'node -v' . it will also install npm. npm is package manager for node.
and it's version will be very different. to check , type in cmd 'npm -v' . node
version changes rapidally. to manage node version use nvm-windows. versioing of
package of packages is handled by small caret like ~ and ^.
==> command line node
to open open command line node type node in command prompt. and can perform
operation there.
alwaya start a project by type npm init. create .npmrc file to setup installation
like --save.
Debugging options
1)console.log
2) chalk
example:
app.listen(3000, function() {
console.log(chalk.green("port is running on port 3000"));
});
3)