LoginSignup
3
3

More than 3 years have passed since last update.

yarn で http server を立てる

Posted at

yarn のインストール

package.json を作成

yarn init

実行すると, いくつかの項目を入力を促されますが, 特に変更する必要がなければ Enter を押しましょう

http-serverを追加

yarn add http-server

package.json を編集

script から実行できるよう, package.json に以下を追記しましょう。

 "scripts": {
    "start": "http-server"
  }

index.html を main として立ち上がる package.json は以下のようになります。

{
  "name": "******",
  "version": "1.0.0",
  "main": "index.html",
  "repository": "******.git",
  "author": "******",
  "license": "MIT",
  "scripts": {
    "start": "http-server"
  },
  "dependencies": {
    "http-server": "^0.11.1"
  }
}

yarn を実行

yarn run start

これで, http://localhost:8080 にアクセスすると, index.html が表示されると思います。

3
3
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
3
3