LoginSignup
1
0

More than 3 years have passed since last update.

Node.js, Express, sequelizeで開発を始める際の初期設定

Last updated at Posted at 2019-10-02

はじめに

タイトルのスタックでWebアプリケーションを開発するために、まず何をすべきかいいかを書く。

データベースはSQLiteを使う。

環境

  • Mac
  • Node.js v10.15.3

手順

Expressの初期化

参考:https://expressjs.com/ja/starter/generator.html

npm install express-generator -g

express --view=pug myapp
cd myapp
npm install

# 起動確認
npm start

http://localhost:3000/ にアクセスできればOK

sequelizeの初期化

参考:https://github.com/sequelize/cli

npm install sqlite3 sequelize
npm install --save-dev sequelize-cli

npx sequelize init

設定ファイルに記入

> cat config/config.json
{
  "development": {
      "dialect": "sqlite",
      "storage": "database.sqlite3"
  }
}

DBのマイグレーション(おまけ)

# マイグレーションファイルとモデルのファイルを作成
npx sequelize-cli model:generate --name User --attributes id:integer,name:string,email:string

# マイグレーションを実行
npx sequelize db:migrate

SQLiteでの確認はこちらを参考に。

以上。

リンク

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