node js is like a php
node is a javascript but run on outside browser
node js is completely diffrent from browser js
to check node version node -v
built on chrome v8 engine
we can crud operation with database
developed by ryan dahl in 2009
it is javascript based frame work
it uses javascript on the server
released under mit license
open source completely free
it is a server side platform
build on google chromes javascript v8 engine
what web server does is take a request from client , proces it , takes from databse and send to client
crud using nodejs
node js is a server side environment
we can develop web applicatiaons, apis using nodejs
node js is afree open source
it can work on any os like linux, mac and windows
]
how to use console for testing node or javasript
there is no wndow in object because its not run in browesr
nodejs features
it is asychronois and fast driven
means
when server got 2 requests at a time, it will solve and start at a time, didnt wait for completion of firstrequest, bot wil start at a time
very fast
single threaded (only onethread - responds to multiple requiest of the client)
two clients
it takes from one client and responds to taht aclient requiest - if it takes or not takes time
if one client requiest is not complete or complete
it not bother- it takes request from another client it respoids
event driven
higly scalable
no buffering
mit licensed
nodejs uses\\
instala nodejs
from command line also possible
environ ment setup
got to this website - dowload as per ur os and version
https://nodejs.org/en/download/
it will come with run time environment
react hosted on npm
npm is hosted on npmjs.com
it has pacakges and it consists of folders or modules- all files are in shareable js
no quality control- any body can publish in npm js.com
how to tld i is good- number of weekly downloads
if pacakges has bug, any body can resolve that bug if not fixed
npm --v
and npm- package manager - it has predefined modiles
npm - nodejs pacakage manager
npmjs.com
it has thusand of modules whcih we can use modules
before learning nodejs u have to learn
es6 - callbacks, promises, asyc wait
applications
chat applications
game server
streaming servers
i/o and apps
i/o bound appss
open file
save as script.js
write some console .log
run usng node script.js
it willl run
what is npm and howto install npm modles
npm view underscore - it will show all the details of underscore module
then if u need to instal
npm installl underscore
with version
npm install underscore@1.4.0 --save
--save - to reflect changes what u install
npm init-f - package instal for ur installation changes - if package not moified
npm list
to list all the modules
npm init -y (evrything default)
npm init
after running above command - it will generate package.json file
in that below text there
iniitial file
name- name of the programm
version - of ur buliding app
description- about ur buildingapp
entry piont
test command -
git respostiroy - url of git
keywords: finding this prokect
author: developer
licesnace:mit
whatever u install taht willl be reflected in pacakge.json
npm outdated
it will show outdated versions in this pacakge.json
to update outdated versions
use npm update --save
it will update all outdated versions
how to instal package
npm unistall expres --save
to know what packages it has
npm ls
to list the packages of what installed in npm it will show that
not locally install gloabally
npm instal express --gloabl
locatuon not shown present folder
it shows from root of ur pc
means u can use from any folder this express
in local list it will not show
npm ls
it is shown in glovbal installation
npm ls --global
installl local and global npm
npm i packagename
global
npm install -g package name
npm i nodemon -D
npm i nodemon -save -dev
this run every dependencies
loadash
booststrap
npm run start
npm run dev - for every save we not run npm run start, if we run dev
nodemon restart for every change in file
similary npm run start command - we have restrat server for every change to reflect in ui
it will automaticlayy runs whenever new thing added
nodemon means watching my applicatiaon
syncrhonus program step by step
in above programm
ist import fs
then print prograamm started
then read the file
after reading file
print program ended
asyncronous programm
below
in above programm
ist import fs
then print programm started
then read file
read file function is going on
iwithout waiting for read it will print program ended
but reading file happends when reading file over it will print taht data
as soon as reading file overs- it callbacks and print the text
one function willl not depends on another function to execute
but line by line
node js call backs
how the actual programm is
package.lock.json is created for locking the dependency with the installed version. It will install the exact latest version of that package in your application and save it in package.json. Let’s say if the current version of the package is 1.3.2 then it will save the version with (^) sign. Here carot(^) means, it will support any higher version with major version 1 for eg. 1.2.2.
Without package.lock.json, there might be some differences in installed versions in different environments. To overcome this problem, package.lock.json is created to have the same results in every environment. It should be in source control with the package.json file because if any other user will clone the project and install dependencies then it will install the exact same dependencies as in package.lock.json to avoid differences.
It is automatically generated for those operations where npm modifies either node_modules tree or package.json
if u install again using npm installin another server
that will install from package.lock json only
event loops
No comments:
Post a Comment