| ページ一覧 | ブログ | twitter |  書式 | 書式(表) |

MyMemoWiki

「Express」の版間の差分

提供: MyMemoWiki
ナビゲーションに移動 検索に移動
(ページの作成:「| Node.js | Google App Engine | Google Cloud Platform | ==Express==」)
 
 
(同じ利用者による、間の12版が非表示)
1行目: 1行目:
| [[Node.js]] | [[Google App Engine]] | [[Google Cloud Platform]] |
+
| [[Node.js]] | [[TypeScript]] | [[Google App Engine]] | [[Google Cloud Platform]] |
 
==Express==
 
==Express==
 +
{{amazon|B00KRB9U2G}}
 +
 +
===アプリケーション生成===
 +
*https://expressjs.com/ja/starter/generator.html
 +
====インストール====
 +
<pre>
 +
$ npm install -g express-generator
 +
</pre>
 +
*Help
 +
<pre>
 +
$ express -h
 +
 +
  Usage: express [options] [dir]
 +
 +
  Options:
 +
 +
        --version        output the version number
 +
    -e, --ejs            add ejs engine support
 +
        --pug            add pug engine support
 +
        --hbs            add handlebars engine support
 +
    -H, --hogan          add hogan.js engine support
 +
    -v, --view <engine>  add view <engine> support (dust|ejs|hbs|hjs|jade|pug|twig|vash) (defaults to jade)
 +
        --no-view        use static html instead of view engine
 +
    -c, --css <engine>  add stylesheet <engine> support (less|stylus|compass|sass) (defaults to plain css)
 +
        --git            add .gitignore
 +
    -f, --force          force on non-empty directory
 +
    -h, --help          output usage information
 +
</pre>
 +
*テンプレートエンジン
 +
**[https://pugjs.org/api/getting-started.html Pug],[https://www.npmjs.com/package/ejs EJS],[https://www.npmjs.com/package/jade jade]
 +
 +
====生成====
 +
<pre>
 +
$ express --view=pug testapp
 +
 +
  create : testapp/
 +
  create : testapp/public/
 +
  create : testapp/public/javascripts/
 +
  create : testapp/public/images/
 +
  create : testapp/public/stylesheets/
 +
  create : testapp/public/stylesheets/style.css
 +
  create : testapp/routes/
 +
  create : testapp/routes/index.js
 +
  create : testapp/routes/users.js
 +
  create : testapp/views/
 +
  create : testapp/views/error.pug
 +
  create : testapp/views/index.pug
 +
  create : testapp/views/layout.pug
 +
  create : testapp/app.js
 +
  create : testapp/package.json
 +
  create : testapp/bin/
 +
  create : testapp/bin/www
 +
 +
  change directory:
 +
    $ cd testapp
 +
 +
  install dependencies:
 +
    $ npm install
 +
 +
  run the app:
 +
    $ DEBUG=testapp:* npm start
 +
</pre>
 +
====実行====
 +
<pre>
 +
$ npm start
 +
</pre>
 +
[[File:express_pug.png|400px]]
 +
===[[Pug]]===
 +
*[[Pug]]

2020年10月29日 (木) 12:15時点における最新版

| Node.js | TypeScript | Google App Engine | Google Cloud Platform |

Express

アプリケーション生成

インストール

$ npm install -g express-generator
  • Help
$ express -h

  Usage: express [options] [dir]

  Options:

        --version        output the version number
    -e, --ejs            add ejs engine support
        --pug            add pug engine support
        --hbs            add handlebars engine support
    -H, --hogan          add hogan.js engine support
    -v, --view <engine>  add view <engine> support (dust|ejs|hbs|hjs|jade|pug|twig|vash) (defaults to jade)
        --no-view        use static html instead of view engine
    -c, --css <engine>   add stylesheet <engine> support (less|stylus|compass|sass) (defaults to plain css)
        --git            add .gitignore
    -f, --force          force on non-empty directory
    -h, --help           output usage information

生成

$ express --view=pug testapp

   create : testapp/
   create : testapp/public/
   create : testapp/public/javascripts/
   create : testapp/public/images/
   create : testapp/public/stylesheets/
   create : testapp/public/stylesheets/style.css
   create : testapp/routes/
   create : testapp/routes/index.js
   create : testapp/routes/users.js
   create : testapp/views/
   create : testapp/views/error.pug
   create : testapp/views/index.pug
   create : testapp/views/layout.pug
   create : testapp/app.js
   create : testapp/package.json
   create : testapp/bin/
   create : testapp/bin/www

   change directory:
     $ cd testapp

   install dependencies:
     $ npm install

   run the app:
     $ DEBUG=testapp:* npm start

実行

$ npm start

Express pug.png

Pug