当記事の目的
Express(Webアプリ)のサンプルを作成。
プロジェクト用フォルダを作成
mkdir myapp
cd myapp
プロジェクト用packege.json作成
npm init
Expressパッケージをインストール
npm install express --save
インストール済みのパッケージを確認
npm list --depth=0
`-- express@4.17.1
各種ファイル作成
myapp ディレクトリーで、app.js というファイルを作成
app.js
const express = require('express')
const app = express()
app.get('/', (req, res) => res.send('Hello World!'))
app.listen(3000, () => console.log('Example app listening on port 3000!'))
起動
> node app.js
Example app listening on port 3000!
画面
参考
Express
https://expressjs.com/