嗨,幫派,在此websockets教程中,我將向您展示如何在Node.js上啟動並運行一個非常簡單的Express應用程序,以準備使用websockets。
—–課程鏈接:
+回購-https://github.com/iamshaunjp/websockets-playlist
+ Atom編輯器-https://atom.io/a
+下載節點-https://nodejs.org/en/
+ Socket.io-https://socket.io
————————————————– ——————————————-
相關教程:
—– NODE.JS教程
—–訂閱頻道-https://www.youtube.com/channel/UCW5YeuERMmlnqo4oq8vwUpg?sub_confirmation=1
==============網路忍者=====================
有關更多的前端開發教程並精通您的編碼技能,請訪問-https://www.youtube.com/channel/UCW5YeuERMmlnqo4oq8vwUpg或http://thenetninja.co.uk
==================社交鏈接==================
Twitter-@TheNetNinja-https://twitter.com/thenetninjauk。
to bypass the npm questionnaire:
npm init -y
the repo isn't working anymore ;( i find this tutorial very helpful
What is the font you're using on Atom? I know it's not a monospaced but it looks pretty neat and I want to use it in my website. Thanks!
CSS:
body{
font-family: 'Nunito';
}
h2{
font-size: 18px;
padding: 10px 20px;
color: #575ed8;
}
#mario-chat{
max-width: 600px;
margin: 30px auto;
border: 1px solid #ddd;
box-shadow: 1px 3px 5px rgba(0,0,0,0.05);
border-radius: 2px;
}
#chat-window{
height: 400px;
overflow: auto;
background: #f9f9f9;
}
#output p{
padding: 14px 0px;
margin: 0 20px;
border-bottom: 1px solid #e9e9e9;
color: #555;
}
#feedback p{
color: #aaa;
padding: 14px 0px;
margin: 0 20px;
}
#output strong{
color: #575ed8;
}
label{
box-sizing: border-box;
display: block;
padding: 10px 20px;
}
input{
padding: 10px 20px;
box-sizing: border-box;
background: #eee;
border: 0;
display: block;
width: 100%;
background: #fff;
border-bottom: 1px solid #eee;
font-family: Nunito;
font-size: 16px;
}
button{
background: #575ed8;
color: #fff;
font-size: 18px;
border: 0;
padding: 12px 0;
width: 100%;
border-radius: 0 0 2px 2px;
}
awesome
Off the topic, this is like the best express tutorial I've ever seen
If I open a browser using chrome address http//:localhost:4000 I get a failed to load page. Doesn't work for me I'm afraid unless someone can help? I installed the Atom package to view in browser, but it took me to port 8081 for some reason. Manually changing it to 4000 also didn't work. Also why do I have a package-lock.json file?
I subscribed to see more mario references in your coding exercises
I'm trying to make a multiplayer connect 4 game and this really helps a lot thanks!
where can i find the css files, the repo is empty
No demon.
If my mind sees it that way I want to infect everyone else
Thanks bro!
Thank You
your websockets repository seems to be empty
css file on github -> https://github.com/iamshaunjp/websockets-playlist/blob/lesson-2/public/styles.css
require not working i did same steps you did
On app.use(express.static(『public』));
What would I do if I wanted to load a file for index.php instead of index.html
If there are any problems for nodemon index, use following steps
1. npm install nodemon -g
2. nodemon 🙂
If you dont install nodemon globally , u can write in package.json
"scripts": {
"start": "nodemon index"
}
And in cmd use : npm run start
some cmd i can not follow in command line. i use windows 10 same with you i use command same with you
If you want an abridged written guide, you may want to check out the github repo below:
https://github.com/danhagg/ChatApp_Websockets
Hi apologies but can I ask if the files on your Git are still there? Because I'm trying to follow the tutorial but the only files that I see on the Git are gitignore and READme file. Would really appreciate if someone can help me out with this! Thanks for tutorial though! Really helpful so far.
Nice work @ TheNetNinja
Please how can I use my chat in the browser without going to my console to start the server we created?
Thank you so much for this series! You have assisted me to get my Fishtank controller (using GPIO pins on a Raspberry Pi) started and I am stoked with the results. I struggled with some of the other tutorials I was trying to follow. Your simple example was clearly explained and easy to follow.
excellent series, thanks for sharing
where is the css file not on current repo u located
use this to install nodemon on the site
npm install -g nodemon
Can this server be done in any other tech or must it be on Express in order to use Socket.io?
At some point in the video you should've mentioned what an express app is.
Just realised the channel I'm on, keep finding your videos without intending to, keep up the good work! Realised when I saw your repo structure haha!
var server = app.listen(4000.function(){
^^^^^
SyntaxError: Invalid or unexpected token
at new Script (vm.js:79:7)
at createScript (vm.js:251:10)
at Object.runInThisContext (vm.js:303:10)
at Module._compile (internal/modules/cjs/loader.js:656:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:741:12)
at startup (internal/bootstrap/node.js:285:19)
2:31 Isn't it simpler to just use VSCode + live-server plugin?
Hi Thanks for the tutorial. Could you please explain using getUserMedia(). I have to implement Audio/Video Chat application. Thanks again.
Hi, can you do a tutorial on socket.io without express .
Yoh Shaun, i have a question: When you make a chat app, do you host the server app? If yes how would the url look, so that its inaccessible through a normal browser, and that it is only accessible through the mobile app and the client website that contains the chat app that the users can use? Thanks for the videos, they're awesome
PS if Shaun doesn't reply or if you see this before him, please help out if you know whats happening here
Which Syntax Theme you're using? 😀
Don't forget to download nodemon before using it, to install just type
npm install nodemon
I have a doubt. When i do app.use(express.static('public')); , why does it not work unless the html file in the public folder is named index.html?? i tried renaming file to st.html but when i run on the browser, it says CANNOT GET/. it only works when it is index.html
Hi. I'm following this tutorial line by line. I noticed when I run nodemon, it returns a message saying that nodemon is not recognized. How do I fix that?
I really love the faster pace! <3