Node + Express 完全新手教學 - 1 [環境設定 + Node Hello World]
這篇是做個簡單的教學 一步一步的操作重安裝到實際頁面製作出來
[PS 這邊不包含DB建立跟連接 會再另外一篇在做介紹]
1. Download Form NodeJS Websit :
[推薦LTS版本]

2.開啟CMD/終端機Check 是否安裝完成:

因該會出現你的版本
2-1:
一個簡單的Node 官方的 Hello World:
在終端機下 打node
會變成>
把下方的code執行後
打開你的瀏覽器
localhost:1337
你就會看到你的第一個'Hello World '

3.安裝express:
這邊請開始使用NodeJS command prompt

安裝Express Global
Mac底下請加上 sudo:
安裝完畢check 安裝成功與否
4.建立project資料夾跟package.json:
[ex: 我是在D:\nodeJStest\]
我們可以利用 npm init 建立這個package.json檔案
他會問一些問題:

就會幫你建立好了(灑花)
[簡單說明一下 這個檔案就是一個目錄檔 你這個node js app所需要用到的其他關聯的軟體阿 ,授權阿,作者阿, 其實就像是書本的目錄]
5.把express 加入 package.json
這個--save指令做多做了一件事情
1.把有調用的軟體加入 package.json

[PS 這邊不包含DB建立跟連接 會再另外一篇在做介紹]
1. Download Form NodeJS Websit :
[推薦LTS版本]

2.開啟CMD/終端機Check 是否安裝完成:
node -v

因該會出現你的版本
2-1:
一個簡單的Node 官方的 Hello World:
在終端機下 打node
會變成>
把下方的code執行後
const http = require('http');
const hostname = '127.0.0.1';
const port = 1337;
http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Hello World\n');
}).listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});
打開你的瀏覽器
localhost:1337
你就會看到你的第一個'Hello World '

3.安裝express:
這邊請開始使用NodeJS command prompt

安裝Express Global
npm install express -g
Mac底下請加上 sudo:
sudo npm install express -g
安裝完畢check 安裝成功與否
express --version
4.建立project資料夾跟package.json:
[ex: 我是在D:\nodeJStest\]
我們可以利用 npm init 建立這個package.json檔案
npm init
他會問一些問題:

就會幫你建立好了(灑花)
[簡單說明一下 這個檔案就是一個目錄檔 你這個node js app所需要用到的其他關聯的軟體阿 ,授權阿,作者阿, 其實就像是書本的目錄]
5.把express 加入 package.json
npm install express --save
這個--save指令做多做了一件事情
1.把有調用的軟體加入 package.json
