10
4

More than 3 years have passed since last update.

Node.jsで簡単にサーバーを立てる

Last updated at Posted at 2020-03-09

Node.jsでサーバーを立てるモジュールについて書きます。

前提条件

  • npmがインストールされていること
  • package.jsonがあること

インストール

$ npm install -D http-server

使い方

設定

npm run serverコマンドでhttp-serverを動かすように定義します。

package.json
{
  "scripts": {
    "server": "http-server -o"
  }
}

実行

npmコマンドを実行します。

$ npm run server

出力結果

Starting up http-server, serving ./
Available on:
http://127.0.0.1:8080

出てきたパスを叩けば現在のディレクトリのファイルを見ることができます。

参考文献

この記事は以下の情報を参考にして執筆しました。

10
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
4