1
0

More than 1 year has passed since last update.

Expressフレームワークの使い方

Posted at

Expressとは

Expressとは、node.jsのWebアプリケーション・フレームワークです。

Expressの始め方

express-generatorをインストールすると、アプリ開発の雛形を素早く生成することができます。

npm install -g express-generator
express アプリ名

で、開発フォルダを生成します。

express test      

今回はtestとします。
また、テンプレートエンジンを指定しないとこのように自動的にjadeを使用するという注意ができます。

  warning: the default view engine will not be jade in future releases
  warning: use `--view=jade' or `--help' for additional options

テンプレートエンジンを指定するときは、

express --view=pug test

のようにしなければいけません。
testディレクトリに入ると、
スクリーンショット 2022-03-10 22.59.10.png
このような状態になっています。
そして、自分が作ったディレクトリの中で、

npm install

依存関係をインストールしないといけません。
実際に、

DEBUG=myapp:* npm start

コマンドを実行し、localhost:3000を開くとスクリーンショット 2022-03-10 23.04.19.png
このような画面になっていると思います!

1
0
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
1
0