Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install Node.js and live-server on Ubuntu 16.04 #6

Open
shyangs opened this issue Mar 1, 2017 · 0 comments
Open

Install Node.js and live-server on Ubuntu 16.04 #6

shyangs opened this issue Mar 1, 2017 · 0 comments

Comments

@shyangs
Copy link
Owner

shyangs commented Mar 1, 2017

live-server 的用途:

安裝

需要依序安裝的有 curl, Node.js (和 npm), live-server

  1. 首先安裝 curl, 按下 Ctrl + Alt + T, 開啟 Terminal, 輸入下列指令
    sudo apt install curl
  2. 按照 Node.js 官網的安裝指示,安裝 Node.js (和 npm)
    curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
    sudo apt-get install -y nodejs

Install Node.js

  1. 安裝 live-server
    sudo npm install -g live-server
  2. 接下來我們測試一下. 在桌面新增一個資料夾 TodoApp , 用 sublime (或其他文字編輯器) 建一個 index.html 檔案,內容為:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Examples</title>
<meta name="description" content="">
<meta name="keywords" content="">
<link href="" rel="stylesheet">
</head>
<body>
    <div>Hello, world!</div>
</body>
</html>
  1. Terminal 切換路徑到上述 index.html 檔案所在路徑 ( 在此例為 cd 桌面/TodoApp/ ),輸入命令live-server,將會啟動伺服器,開啟瀏覽器,前往 http://localhost:8080index.html 檔案會顯示Hello, world!在網頁上。
    live-server: Hello, world!

  2. 如果出現Error: listen EACCES {{path}}:{{port}}錯誤訊息,可能是該port被本機其他伺服器佔據了,請換其他port,比如 live-server --host=127.0.0.1 --port=1234
    註: EACCES (aka "Permission denied")

  3. 如果出現'live-server' 不是內部或外部命令、可執行的程式或批次檔。(live-server: command not found) 請檢查環境變數 PATH的設定值。(Windows 裡應加入 ;C:\Program Files\nodejs;%AppData%\npm;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant