1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

express-generator の使い方

Last updated at Posted at 2022-01-30

次のページを参考にしました。
Express のアプリケーション生成プログラム

ライブラリーのインストール

sudo npm install express-generator -g

プロジェクトの作成

express --view=pug myapp

依存関係をインストール

cd myapp
npm install

サーバーの起動

DEBUG=myapp:* npm start

クライアントでポート 3000 にアクセスする

http http://localhost:3000

ソースを改造

views/index.pug
extends layout

block content
  h1= title
  p Welcome to #{title}
  p Hello World!
  p こんにちは

クライアントでアクセス
express_jan31.png

forever でデーモン化

ライブラリーのインストール

sudo npm install forever -g

起動

forever start ./bin/www
$ forever start ./bin/www
warn:    --minUptime not set. Defaulting to: 1000ms
warn:    --spinSleepTime not set. Your script will exit if it does not stay up for at least 1000ms
info:    Forever processing file: ./bin/www
(node:20939) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
(node:20939) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency

状況の確認

forever list

停止

forever stopall

ポートを指定しての起動

PORT=5000 forever start ./bin/www

確認したバージョン

$ node --version
v20.2.0

$ express --version
4.16.1
1
2
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
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?