Hello. This is a very good series. Thank you! In Ubuntu 16 I had to install nodemon globally to work (with parameter -g): npm install nodemon -g --save-dev
If you don't have nodemon in path and it's not being found. Then you can run it from the node_modules folder.... I have node in path , but nothing else. like so: node node_modules/nodemon/bin/nodemon index
Very helpful thanks mate. For those that don't understand npx, it's just a replacement to run packages in your node_modules when it's not installed globally. As thisguyistoofly advised, its encouraged to not install it globally.
for any of you who get '-nodemon' is not recognized as an internal or external command, operable program or batch file. try npm install -g nodemon first
app.use('/api', routes); is way cleaner than app.use('/api', require('./routes/api.js')); I don't know why you decided to change that :p Awareness that u can do it maybe?
Because there is no need to take up memory with a constant, if you're only going to use it once in the code. I agree that the first option looked cleaner, however.
Hey there, Thanks a ton for these videos! Frankly speaking, I haven't found much videos around in regards to NodeJS + ExpressJS that can explain in detail the way you do in a short 12:20 mins. Great great stuff! Now for my questions...I get the fact that we use app.use(routes); so that index can see api.js....But what advantage does app.use('/api', routes) give? Isn't it just extra typing to do so when localhost:3000/ninjas works perfectly? Thank you :) Keep up the amazing videos!
Hey, good question. Using the express Router to split the routes is that we can make many different 'mini' apps, if you like. Yeah, we could use just /ninjas without using the router for the '/api/' section, but this way we could potentially have a /ninjas page which wasn't part of the api. Hope this makes sense.
Hello, thanks for great tut. As we require express in two seperate files are there two different express objects or are these two objects same and shared in both files? Is the program chaching the first express obj and using it in the second router file?
I don't really understand why we have are working with 2 port numbers. Is 4000 the port number of the local server, where the website is hosted, and 27017 the port number of the local server, where the database is stored?
Thank you for the tutorial! Quick question, though: I see that on the get method, you use router.get('/ninjas', function(req, res) { res.send({type: 'GET'}) }) Is there any particular problem in using an arrow function instead of the normal function for the HTTP methods? Like, router.get('/ninjas', (req, res) => { res.send({type: 'GET'}) }) I've see a lot of people using function over the arrow function for http methods, but as far as I tested there's no difference between the two of them. And arrow functions tend to look cleaner. So I'm just wondering why it seems to be preferred to use the normal function() for these methods. Thanks!
I believe it's just a stylistic choice. I always use arrow functions because they're easier to type and they look cleaner, and I've never had any issues specifically related to using them over the regular anonymous function syntax
Hi, Love your tuts, but im facing an error in this one. when i use "nodemon index" in cmd, it gives the following error : ''nodemon' is not recognized as an internal or external command, operable program or batch file.' Any help?
he already install nodemon globaly before he make this video tutorial. if you already doing -> "npm install nodemon -g" u just need to do "npm install nodemon --save-dev" every you create a project. --save-dev means you save to development dependency on package.json you can visit docs.npmjs.com/cli/install to get complete explanation about CLI command especially install command
Hello, first of all thanks for this series.. I'm facing one problem regarding nodemon command on my PC it shows me following error.. ------------------------------------------------------------------------------------------------------ λ nodemon index 'nodemon' is not recognized as an internal or external command, operable program or batch file. ------------------------------------------------------------------------------------------------------ what should I do?
in package.json, add a new line in "scripts" like this: ---------------------------- "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "serve": "nodemon index.js" }, run like this: ------------------------- npm run serve
nodemon package is installed but if i executed nodemon index means it is showing the error as nodemon is not an a internal or external command please help what i need to do
when i type nodemon index in cmd, they said "nodemon'' is not recognized as an internal or external command, operable program or batch file. I already install nodemon --save-dev. What are the solution ?
someone can explain me how app.use('/api', require('./routes/api.js')); influence the code. If I understand well the request of user reach firstly app.js, wich handle the routes taken by the user request. But I can't definitely understand how this snippet works. Someone can explain me what the function app.use('/api', require('./routes/api.js')); does step by step please ? Kind regard
@Horizon Coding, Here is the explanation app.use('/api', require('./routes/api.js')) basically tells server that if you get request for '/api' then please use the file located under './routes/api.js' . And /routes/api.js file will have get/post/put/delete request inside it.
These videos have helped me more than my teacher has. Thank you so much for these lessons. Keep up the great work!
i have no words........!!what a series // Awesome Awesome Awesome!!!!!
Hours of mumbo jumbo from a teacher, explained in 12m of complete excellence xD
Excellent course, thanks for providing us such beautiful contents Shaun !
The best rest api tutorial series!!! The Net Ninja is awesome!!!
Everthing " Makes Sense " .
Greate job !
Very well explained series. Thanks.
Hello. This is a very good series. Thank you!
In Ubuntu 16 I had to install nodemon globally to work (with parameter -g):
npm install nodemon -g --save-dev
If you don't have nodemon in path and it's not being found. Then you can run it from the node_modules folder.... I have node in path , but nothing else.
like so:
node node_modules/nodemon/bin/nodemon index
No reason to save dev for global npm installs, doesn't do anything. If running locally you could do "npx nodemon" and it will magically work
Very helpful thanks mate. For those that don't understand npx, it's just a replacement to run packages in your node_modules when it's not installed globally. As thisguyistoofly advised, its encouraged to not install it globally.
for any of you who get '-nodemon' is not recognized as an internal or external command,
operable program or batch file. try npm install -g nodemon first
at 0:45
Instead of
$ npm install nodemon --save-dev
I had to use
$ npm install -g nodemon
Something others might have faced on Ubuntu 16.04 LTS.
I was going to comment the same. Thanks anyway
my window 10 machine also use this command instead of what Ninja’d mentioned.
My gawd... This is required reading for anyone curious about building with the ME_N stack....
This is awesome, thanks alot.
Wonderfully explained! Thanks
Great Series!! You're the best Thank you for making it so easy!
Thank you very much! Very well explained!
app.use('/api', routes);
is way cleaner than
app.use('/api', require('./routes/api.js'));
I don't know why you decided to change that :p Awareness that u can do it maybe?
Because there is no need to take up memory with a constant, if you're only going to use it once in the code. I agree that the first option looked cleaner, however.
My thoughts too, so in my files i kept it the way it was... i didnt make the changes he made.
very good vedio for beginners
Great explanation. Thanks a lot!
npm install -g nodemon --save-dev
is also required on windows. some people have mentioned how its needed for ubuntu.
Hey there, Thanks a ton for these videos! Frankly speaking, I haven't found much videos around in regards to NodeJS + ExpressJS that can explain in detail the way you do in a short 12:20 mins. Great great stuff!
Now for my questions...I get the fact that we use app.use(routes); so that index can see api.js....But what advantage does app.use('/api', routes) give? Isn't it just extra typing to do so when localhost:3000/ninjas works perfectly?
Thank you :) Keep up the amazing videos!
Hey, good question. Using the express Router to split the routes is that we can make many different 'mini' apps, if you like. Yeah, we could use just /ninjas without using the router for the '/api/' section, but this way we could potentially have a /ninjas page which wasn't part of the api. Hope this makes sense.
The Net Ninja. I see. Yes, that makes perfect sense. Thanks!
Hello, thanks for great tut. As we require express in two seperate files are there two different express objects or are these two objects same and shared in both files? Is the program chaching the first express obj and using it in the second router file?
well according to below link in es6 alltough you require same obj in seperate file it is the same object and it is called immutable binding.
I don't really understand why we have are working with 2 port numbers.
Is 4000 the port number of the local server, where the website is hosted,
and 27017 the port number of the local server, where the database is stored?
a list of ninjas ! hahha .. you are really serious about being a ninja aren't u ?
In the following tutorial of routes....url is same for get and post, put and delete...how to check the each case of route in browser
جميل جدا شكرا لك
must app.listen be at the bottom of the file? does the order matter?
10:55 🤣
Great Videos Bro, When you will release new ones?
nice video. I want to do it on linux RHEL 7 (VM) and need to expose it for production. Need guidance
Thank you for the tutorial!
Quick question, though:
I see that on the get method, you use
router.get('/ninjas', function(req, res) {
res.send({type: 'GET'})
})
Is there any particular problem in using an arrow function instead of the normal function for the HTTP methods?
Like,
router.get('/ninjas', (req, res) => {
res.send({type: 'GET'})
})
I've see a lot of people using function over the arrow function for http methods, but as far as I tested there's no difference between the two of them. And arrow functions tend to look cleaner. So I'm just wondering why it seems to be preferred to use the normal function() for these methods.
Thanks!
interesting question.
I believe it's just a stylistic choice. I always use arrow functions because they're easier to type and they look cleaner, and I've never had any issues specifically related to using them over the regular anonymous function syntax
Hey Ninja, what's the advantage of using router.get() over app.get()? Why not create a new file and pass the app as parameter like in previous series?
Nvm found it here: scotch.io/tutorials/learn-to-use-the-new-router-in-expressjs-4
When you use exports and then imports by require('/routes/api'). Can data flow both ways?
Hi,
Love your tuts, but im facing an error in this one.
when i use "nodemon index" in cmd, it gives the following error :
''nodemon' is not recognized as an internal or external command,
operable program or batch file.'
Any help?
you should instal nodemon globaly on your pc
npm install -g nodemon --save-dev
Wisnu Arya Dipa
Then how does it work in the video without it?
he already install nodemon globaly before he make this video tutorial.
if you already doing -> "npm install nodemon -g" u just need to do "npm install nodemon --save-dev" every you create a project.
--save-dev means you save to development dependency on package.json
you can visit docs.npmjs.com/cli/install to get complete explanation about CLI command especially install command
npm install -g nodemon --save-dev
followed by
npm install nodemon --save-dev
Worked for me.....thanks peeps
"npx nodemon"
are you going to cover rest api using https package
TypeError: app.use() requires middleware functions
What is the issue here?
Might have done the same mistake as me.
I wrote export, and not exports in the api.js file.
module.exports = router;
And I had the same error as you.
Thanks man!
i made exactly the same mistake
=
Thank you!
@@KarDiamond haha i made the same mistake. thanks
why don't I use just app.get for the whole routing instead of using route.get and so ... ?
For organization, also for larger projects we would need to use a separate file for our routes,instead of cluttering our index.js with all the code
but we could have used a separate file and passed the app as a parameter and used app.get instead
this is a good read on why u should start using this.
scotch.io/tutorials/learn-to-use-the-new-router-in-expressjs-4
It says cannot get...
is it '/ninjas' in a folder ??
Your tutorial is 11:07 :)
Hello, first of all thanks for this series..
I'm facing one problem regarding nodemon command on my PC it shows me following error..
------------------------------------------------------------------------------------------------------
λ nodemon index
'nodemon' is not recognized as an internal or external command,
operable program or batch file.
------------------------------------------------------------------------------------------------------
what should I do?
in package.json, add a new line in "scripts" like this:
----------------------------
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"serve": "nodemon index.js"
},
run like this:
-------------------------
npm run serve
Wohoo!.. It Works!!
Thank you ;)
nice one thanks!
Thanks, it worked. I think the reason for it not working is something to do with the $PATH variable.
What I Just Did Is reinstall the nodemon again but globally with this commend
npm install nodemon -g --save-dev
nodemon package is installed but if i executed
nodemon index means it is showing the error as nodemon is not an a internal or external command
please help what i need to do
try running it inside of your project files, because thats where you installed your nodemon modules. Hope that will solve your problem
nodemon didn't work on ubuntu, even 'npm install nodemon -g' didn't help
why do u publish those videos free instead of selling
when i type nodemon index in cmd, they said "nodemon'' is not recognized as an internal or external command, operable program or batch file. I already install nodemon --save-dev. What are the solution ?
am going to assume you ran that command outside of your project files.
make it global: npm install -g nodemon
someone can explain me how app.use('/api', require('./routes/api.js')); influence the code. If I understand well the request of user reach firstly app.js, wich handle the routes taken by the user request. But I can't definitely understand how this snippet works.
Someone can explain me what the function app.use('/api', require('./routes/api.js')); does step by step please ?
Kind regard
@Horizon Coding, Here is the explanation
app.use('/api', require('./routes/api.js')) basically tells server that if you get request for '/api' then please use the file located under './routes/api.js' .
And /routes/api.js file will have get/post/put/delete request inside it.