続きです。
6.Dashboardから新規アプリ作成
ここで、herokuのDashboardを見ると、作成したサンプルアプリが見えています。今回の場合、mysterious-river-xxxxが作成したサンプルアプリです。
また、右上の「+」が新規アプリ作成に使用するボタンのようです。
「+」を押すと新規アプリケーションの名前を聞いてきます。ただ、optionalなので、そのまま「Create App」してみます。
「whispering-lake-8767」という名前のアプリになったようです。続けてやるべきことが記載されています。これに沿って、アプリケーションのリポジトリを作成してみます。
~/heroku $ mkdir hello-heroku ~/heroku $ cd hello-heroku/ ~/heroku/hello-heroku $ git init Initialized empty Git repository in /home/xxx/heroku/hello-heroku/.git/ ~/heroku/hello-heroku $ heroku login Enter your Heroku credentials. Email: xxxxxxxxxx@xxxxx.xxx Password (typing will be hidden): Authentication successful. ~/heroku/hello-heroku $ heroku git:remote -a whispering-lake-8767 Installing Heroku Toolbelt v4... done Installing plugin heroku-git... done set git remote heroku to https://git.heroku.com/whispering-lake-8767.git ~/heroku/hello-heroku $
として、アプリケーションのリポジトリを作りました。
7. Node.jsでアプリケーションを作成
以下の内容のサンプルアプリを作ってみました。内容は参考にさせていただいたこちらのサイトそのままです。ファイル名はhello.jsとしました。
var express = require("express"); var app = express(); app.use(express.logger()); app.get('/', function(request, response) { response.send('Hello Heroku world!'); }) var port = process.env.PORT || 5000; app.listen(port, function() { console.log("Listening on " + port); });
8. package.jsonファイルを作成
次に、packages.jsonファイルを作成します。
~/heroku/hello-heroku $ npm init This utility will walk you through creating a package.json file. It only covers the most common items, and tries to guess sane defaults. See `npm help json` for definitive documentation on these fields and exactly what they do. Use `npm install <pkg> --save` afterwards to install a package and save it as a dependency in the package.json file. Press ^C at any time to quit. name: (hello-heroku) version: (1.0.0) 0.0.1 description: Study for heroku and node.js entry point: (hello.js) test command: git repository: https://git.heroku.com/whispering-lake-8767.git keywords: Hello World author: license: (ISC) About to write to /home/tom/heroku/hello-heroku/package.json: { "name": "hello-heroku", "version": "0.0.1", "description": "Study for heroku and node.js", "main": "hello.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { "type": "git", "url": "https://git.heroku.com/whispering-lake-8767.git" }, "keywords": [ "Hello", "World" ], "author": "", "license": "ISC" } Is this ok? (yes) ~/heroku/hello-heroku $
これで packages.jsonファイルが作成されました。
・・・が、(予想通りですが)依存関係などは手動で追加のようです。
各パッケージのバージョンを調べます。
~/heroku/hello-heroku $ node -v v0.10.37 ~/heroku/hello-heroku $ npm --version 1.4.28 ~/heroku/hello-heroku $ npm view express version 4.13.1 ~/heroku/hello-heroku $
ということで、packages.jsonファイルを修正します。
{ "name": "hello-heroku", "version": "0.0.1", "dependencies": { "express": "4.13.x" }, "engines": { "node": "0.10.x", "npm": "1.4.x" } }
9. npmで必要なパッケージをインストール
npmで必要になるパッケージをインストールします。
~/heroku/hello-heroku $ npm install npm WARN package.json hello-heroku@0.0.1 No description npm WARN package.json hello-heroku@0.0.1 No repository field. npm WARN package.json hello-heroku@0.0.1 No README data express@4.13.1 node_modules/express ├── escape-html@1.0.2 ├── merge-descriptors@1.0.0 ├── cookie@0.1.3 ├── path-to-regexp@0.1.6 ├── utils-merge@1.0.0 ├── cookie-signature@1.0.6 ├── methods@1.1.1 ├── fresh@0.3.0 ├── range-parser@1.0.2 ├── array-flatten@1.1.0 ├── vary@1.0.1 ├── etag@1.7.0 ├── content-type@1.0.1 ├── parseurl@1.3.0 ├── serve-static@1.10.0 ├── content-disposition@0.5.0 ├── depd@1.0.1 ├── on-finished@2.3.0 (ee-first@1.1.1) ├── finalhandler@0.4.0 (unpipe@1.0.0) ├── qs@4.0.0 ├── debug@2.2.0 (ms@0.7.1) ├── proxy-addr@1.0.8 (forwarded@0.1.0, ipaddr.js@1.0.1) ├── send@0.13.0 (destroy@1.0.3, statuses@1.2.1, ms@0.7.1, mime@1.3.4, http-errors@1.3.1) ├── type-is@1.6.5 (media-typer@0.3.0, mime-types@2.1.3) └── accepts@1.2.11 (negotiator@0.5.3, mime-types@2.1.3) ~/heroku/hello-heroku $
10. Procfileの作成
Procfileを作成してプロセスタイプを宣言します。
web: node hello.js
ここまでで以下のファイルが準備できました。
~/heroku/hello-heroku $ ls -la 合計 28 drwxr-xr-x 4 xxx xxx 4096 7月 23 13:06 . drwxr-xr-x 4 xxx xxx 4096 7月 23 12:28 .. drwxr-xr-x 7 xxx xxx 4096 7月 23 12:29 .git -rw-r--r-- 1 xxx xxx 20 7月 23 13:06 Procfile -rw-r--r-- 1 xxx xxx 280 7月 23 12:36 hello.js drwxr-xr-x 3 xxx xxx 4096 7月 23 12:50 node_modules -rw-r--r-- 1 xxx xxx 162 7月 23 12:49 package.json ~/heroku/hello-heroku $
11. ローカルからアプリを動かしてみる。
ローカルからアプリを動かしてみると・・・
~/heroku/hello-heroku $ foreman start 13:08:41 web.1 | started with pid 3965 13:08:41 web.1 | 13:08:41 web.1 | Error: Most middleware (like logger) is no longer bundled with Express and must be installed separately. Please see https://github.com/senchalabs/connect#middleware. 13:08:41 web.1 | at Function.Object.defineProperty.get (/home/xxx/heroku/hello-heroku/node_modules/express/lib/express.js:99:13) 13:08:41 web.1 | at Object.<anonymous> (/home/xxx/heroku/hello-heroku/hello.js:3:17) 13:08:41 web.1 | at Module._compile (module.js:456:26) 13:08:41 web.1 | at Object.Module._extensions..js (module.js:474:10) 13:08:41 web.1 | at Module.load (module.js:356:32) 13:08:41 web.1 | at Function.Module._load (module.js:312:12) 13:08:41 web.1 | exited with code 8 13:08:41 web.1 | at Function.Module.runMain (module.js:497:10) 13:08:41 system | sending SIGTERM to all processes 13:08:41 | at startup (node.js:119:16) 13:08:41 | at node.js:935:3 ~/heroku/hello-heroku $
となってエラーになってしまいました。
読んでみると、「たいていのミドルウェア(loggerのようなもの)はExpressにはもはやバンドルされてないので個別にインストールしなきゃダメよ。https://github.com/senchalabs/connect#middleware を見てね。」だそうです。
が、リンク先を見ても特にloggerに関する記載はないので、ソースコードを
var express = require("express"); var app = express(); //app.use(express.logger()); app.get('/', function(request, response) { response.send('Hello Heroku world!'); }) var port = process.env.PORT || 5000; app.listen(port, function() { console.log("Listening on " + port); });
として、loggerをコメントアウトして使わないようにしてみました。
すると、
~/heroku/hello-heroku $ foreman start 13:18:58 web.1 | started with pid 4082 13:18:58 web.1 | Listening on 5000
となって、無事起動している模様。ブラウザで見てみると、
となり、無事に表示されました。
12. herokuでアプリを動かす
herokuで動かしてみます。ログが長いですが、後で見返すときのためにそのままで。
~/heroku/hello-heroku $ git init Reinitialized existing Git repository in /home/xxx/heroku/hello-heroku/.git/ ~/heroku/hello-heroku $ git add . ~/heroku/hello-heroku $ git commit -m "1st edition" [master (root-commit) ca0b038] 1st edition 258 files changed, 40123 insertions(+) create mode 100644 Procfile create mode 100644 hello.js create mode 100644 node_modules/express/History.md create mode 100644 node_modules/express/LICENSE create mode 100644 node_modules/express/Readme.md create mode 100644 node_modules/express/index.js create mode 100644 node_modules/express/lib/application.js create mode 100644 node_modules/express/lib/express.js create mode 100644 node_modules/express/lib/middleware/init.js create mode 100644 node_modules/express/lib/middleware/query.js create mode 100644 node_modules/express/lib/request.js create mode 100644 node_modules/express/lib/response.js create mode 100644 node_modules/express/lib/router/index.js create mode 100644 node_modules/express/lib/router/layer.js create mode 100644 node_modules/express/lib/router/route.js create mode 100644 node_modules/express/lib/utils.js create mode 100644 node_modules/express/lib/view.js create mode 100644 node_modules/express/node_modules/accepts/HISTORY.md create mode 100644 node_modules/express/node_modules/accepts/LICENSE create mode 100644 node_modules/express/node_modules/accepts/README.md create mode 100644 node_modules/express/node_modules/accepts/index.js create mode 100644 node_modules/express/node_modules/accepts/node_modules/mime-types/HISTORY.md create mode 100644 node_modules/express/node_modules/accepts/node_modules/mime-types/LICENSE create mode 100644 node_modules/express/node_modules/accepts/node_modules/mime-types/README.md create mode 100644 node_modules/express/node_modules/accepts/node_modules/mime-types/index.js create mode 100644 node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db/HISTORY.md create mode 100644 node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db/LICENSE create mode 100644 node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db/README.md create mode 100644 node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db/db.json create mode 100644 node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db/index.js create mode 100644 node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db/package.json create mode 100644 node_modules/express/node_modules/accepts/node_modules/mime-types/package.json create mode 100644 node_modules/express/node_modules/accepts/node_modules/negotiator/HISTORY.md create mode 100644 node_modules/express/node_modules/accepts/node_modules/negotiator/LICENSE create mode 100644 node_modules/express/node_modules/accepts/node_modules/negotiator/README.md create mode 100644 node_modules/express/node_modules/accepts/node_modules/negotiator/index.js create mode 100644 node_modules/express/node_modules/accepts/node_modules/negotiator/lib/charset.js create mode 100644 node_modules/express/node_modules/accepts/node_modules/negotiator/lib/encoding.js create mode 100644 node_modules/express/node_modules/accepts/node_modules/negotiator/lib/language.js create mode 100644 node_modules/express/node_modules/accepts/node_modules/negotiator/lib/mediaType.js create mode 100644 node_modules/express/node_modules/accepts/node_modules/negotiator/package.json create mode 100644 node_modules/express/node_modules/accepts/package.json create mode 100644 node_modules/express/node_modules/array-flatten/LICENSE create mode 100644 node_modules/express/node_modules/array-flatten/README.md create mode 100644 node_modules/express/node_modules/array-flatten/array-flatten.js create mode 100644 node_modules/express/node_modules/array-flatten/package.json create mode 100644 node_modules/express/node_modules/content-disposition/HISTORY.md create mode 100644 node_modules/express/node_modules/content-disposition/LICENSE create mode 100644 node_modules/express/node_modules/content-disposition/README.md create mode 100644 node_modules/express/node_modules/content-disposition/index.js create mode 100644 node_modules/express/node_modules/content-disposition/package.json create mode 100644 node_modules/express/node_modules/content-type/HISTORY.md create mode 100644 node_modules/express/node_modules/content-type/LICENSE create mode 100644 node_modules/express/node_modules/content-type/README.md create mode 100644 node_modules/express/node_modules/content-type/index.js create mode 100644 node_modules/express/node_modules/content-type/package.json create mode 100644 node_modules/express/node_modules/cookie-signature/.npmignore create mode 100644 node_modules/express/node_modules/cookie-signature/History.md create mode 100644 node_modules/express/node_modules/cookie-signature/Readme.md create mode 100644 node_modules/express/node_modules/cookie-signature/index.js create mode 100644 node_modules/express/node_modules/cookie-signature/package.json create mode 100644 node_modules/express/node_modules/cookie/LICENSE create mode 100644 node_modules/express/node_modules/cookie/README.md create mode 100644 node_modules/express/node_modules/cookie/index.js create mode 100644 node_modules/express/node_modules/cookie/package.json create mode 100644 node_modules/express/node_modules/debug/.jshintrc create mode 100644 node_modules/express/node_modules/debug/.npmignore create mode 100644 node_modules/express/node_modules/debug/History.md create mode 100644 node_modules/express/node_modules/debug/Makefile create mode 100644 node_modules/express/node_modules/debug/Readme.md create mode 100644 node_modules/express/node_modules/debug/bower.json create mode 100644 node_modules/express/node_modules/debug/browser.js create mode 100644 node_modules/express/node_modules/debug/component.json create mode 100644 node_modules/express/node_modules/debug/debug.js create mode 100644 node_modules/express/node_modules/debug/node.js create mode 100644 node_modules/express/node_modules/debug/node_modules/ms/.npmignore create mode 100644 node_modules/express/node_modules/debug/node_modules/ms/LICENSE create mode 100644 node_modules/express/node_modules/debug/node_modules/ms/README.md create mode 100644 node_modules/express/node_modules/debug/node_modules/ms/index.js create mode 100644 node_modules/express/node_modules/debug/node_modules/ms/package.json create mode 100644 node_modules/express/node_modules/debug/package.json create mode 100644 node_modules/express/node_modules/depd/History.md create mode 100644 node_modules/express/node_modules/depd/LICENSE create mode 100644 node_modules/express/node_modules/depd/Readme.md create mode 100644 node_modules/express/node_modules/depd/index.js create mode 100644 node_modules/express/node_modules/depd/lib/compat/buffer-concat.js create mode 100644 node_modules/express/node_modules/depd/lib/compat/callsite-tostring.js create mode 100644 node_modules/express/node_modules/depd/lib/compat/index.js create mode 100644 node_modules/express/node_modules/depd/package.json create mode 100644 node_modules/express/node_modules/escape-html/LICENSE create mode 100644 node_modules/express/node_modules/escape-html/Readme.md create mode 100644 node_modules/express/node_modules/escape-html/index.js create mode 100644 node_modules/express/node_modules/escape-html/package.json create mode 100644 node_modules/express/node_modules/etag/HISTORY.md create mode 100644 node_modules/express/node_modules/etag/LICENSE create mode 100644 node_modules/express/node_modules/etag/README.md create mode 100644 node_modules/express/node_modules/etag/index.js create mode 100644 node_modules/express/node_modules/etag/package.json create mode 100644 node_modules/express/node_modules/finalhandler/HISTORY.md create mode 100644 node_modules/express/node_modules/finalhandler/LICENSE create mode 100644 node_modules/express/node_modules/finalhandler/README.md create mode 100644 node_modules/express/node_modules/finalhandler/index.js create mode 100644 node_modules/express/node_modules/finalhandler/node_modules/unpipe/HISTORY.md create mode 100644 node_modules/express/node_modules/finalhandler/node_modules/unpipe/LICENSE create mode 100644 node_modules/express/node_modules/finalhandler/node_modules/unpipe/README.md create mode 100644 node_modules/express/node_modules/finalhandler/node_modules/unpipe/index.js create mode 100644 node_modules/express/node_modules/finalhandler/node_modules/unpipe/package.json create mode 100644 node_modules/express/node_modules/finalhandler/package.json create mode 100644 node_modules/express/node_modules/fresh/HISTORY.md create mode 100644 node_modules/express/node_modules/fresh/LICENSE create mode 100644 node_modules/express/node_modules/fresh/README.md create mode 100644 node_modules/express/node_modules/fresh/index.js create mode 100644 node_modules/express/node_modules/fresh/package.json create mode 100644 node_modules/express/node_modules/merge-descriptors/LICENSE create mode 100644 node_modules/express/node_modules/merge-descriptors/README.md create mode 100644 node_modules/express/node_modules/merge-descriptors/index.js create mode 100644 node_modules/express/node_modules/merge-descriptors/package.json create mode 100644 node_modules/express/node_modules/methods/HISTORY.md create mode 100644 node_modules/express/node_modules/methods/LICENSE create mode 100644 node_modules/express/node_modules/methods/README.md create mode 100644 node_modules/express/node_modules/methods/index.js create mode 100644 node_modules/express/node_modules/methods/package.json create mode 100644 node_modules/express/node_modules/on-finished/HISTORY.md create mode 100644 node_modules/express/node_modules/on-finished/LICENSE create mode 100644 node_modules/express/node_modules/on-finished/README.md create mode 100644 node_modules/express/node_modules/on-finished/index.js create mode 100644 node_modules/express/node_modules/on-finished/node_modules/ee-first/LICENSE create mode 100644 node_modules/express/node_modules/on-finished/node_modules/ee-first/README.md create mode 100644 node_modules/express/node_modules/on-finished/node_modules/ee-first/index.js create mode 100644 node_modules/express/node_modules/on-finished/node_modules/ee-first/package.json create mode 100644 node_modules/express/node_modules/on-finished/package.json create mode 100644 node_modules/express/node_modules/parseurl/.npmignore create mode 100644 node_modules/express/node_modules/parseurl/HISTORY.md create mode 100644 node_modules/express/node_modules/parseurl/LICENSE create mode 100644 node_modules/express/node_modules/parseurl/README.md create mode 100644 node_modules/express/node_modules/parseurl/index.js create mode 100644 node_modules/express/node_modules/parseurl/package.json create mode 100644 node_modules/express/node_modules/path-to-regexp/LICENSE create mode 100644 node_modules/express/node_modules/path-to-regexp/Readme.md create mode 100644 node_modules/express/node_modules/path-to-regexp/index.js create mode 100644 node_modules/express/node_modules/path-to-regexp/package.json create mode 100644 node_modules/express/node_modules/proxy-addr/HISTORY.md create mode 100644 node_modules/express/node_modules/proxy-addr/LICENSE create mode 100644 node_modules/express/node_modules/proxy-addr/README.md create mode 100644 node_modules/express/node_modules/proxy-addr/index.js create mode 100644 node_modules/express/node_modules/proxy-addr/node_modules/forwarded/HISTORY.md create mode 100644 node_modules/express/node_modules/proxy-addr/node_modules/forwarded/LICENSE create mode 100644 node_modules/express/node_modules/proxy-addr/node_modules/forwarded/README.md create mode 100644 node_modules/express/node_modules/proxy-addr/node_modules/forwarded/index.js create mode 100644 node_modules/express/node_modules/proxy-addr/node_modules/forwarded/package.json create mode 100644 node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/.npmignore create mode 100644 node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/Cakefile create mode 100644 node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/LICENSE create mode 100644 node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/README.md create mode 100644 node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/ipaddr.min.js create mode 100644 node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/lib/ipaddr.js create mode 100644 node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/package.json create mode 100644 node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/src/ipaddr.coffee create mode 100644 node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/test/ipaddr.test.coffee create mode 100644 node_modules/express/node_modules/proxy-addr/package.json create mode 100644 node_modules/express/node_modules/qs/.eslintignore create mode 100644 node_modules/express/node_modules/qs/.npmignore create mode 100644 node_modules/express/node_modules/qs/.travis.yml create mode 100644 node_modules/express/node_modules/qs/CHANGELOG.md create mode 100644 node_modules/express/node_modules/qs/CONTRIBUTING.md create mode 100644 node_modules/express/node_modules/qs/LICENSE create mode 100644 node_modules/express/node_modules/qs/README.md create mode 100644 node_modules/express/node_modules/qs/bower.json create mode 100644 node_modules/express/node_modules/qs/lib/index.js create mode 100644 node_modules/express/node_modules/qs/lib/parse.js create mode 100644 node_modules/express/node_modules/qs/lib/stringify.js create mode 100644 node_modules/express/node_modules/qs/lib/utils.js create mode 100644 node_modules/express/node_modules/qs/package.json create mode 100644 node_modules/express/node_modules/qs/test/parse.js create mode 100644 node_modules/express/node_modules/qs/test/stringify.js create mode 100644 node_modules/express/node_modules/qs/test/utils.js create mode 100644 node_modules/express/node_modules/range-parser/HISTORY.md create mode 100644 node_modules/express/node_modules/range-parser/LICENSE create mode 100644 node_modules/express/node_modules/range-parser/README.md create mode 100644 node_modules/express/node_modules/range-parser/index.js create mode 100644 node_modules/express/node_modules/range-parser/package.json create mode 100644 node_modules/express/node_modules/send/HISTORY.md create mode 100644 node_modules/express/node_modules/send/LICENSE create mode 100644 node_modules/express/node_modules/send/README.md create mode 100644 node_modules/express/node_modules/send/index.js create mode 120000 node_modules/express/node_modules/send/node_modules/.bin/mime create mode 100644 node_modules/express/node_modules/send/node_modules/destroy/README.md create mode 100644 node_modules/express/node_modules/send/node_modules/destroy/index.js create mode 100644 node_modules/express/node_modules/send/node_modules/destroy/package.json create mode 100644 node_modules/express/node_modules/send/node_modules/http-errors/HISTORY.md create mode 100644 node_modules/express/node_modules/send/node_modules/http-errors/LICENSE create mode 100644 node_modules/express/node_modules/send/node_modules/http-errors/README.md create mode 100644 node_modules/express/node_modules/send/node_modules/http-errors/index.js create mode 100644 node_modules/express/node_modules/send/node_modules/http-errors/node_modules/inherits/LICENSE create mode 100644 node_modules/express/node_modules/send/node_modules/http-errors/node_modules/inherits/README.md create mode 100644 node_modules/express/node_modules/send/node_modules/http-errors/node_modules/inherits/inherits.js create mode 100644 node_modules/express/node_modules/send/node_modules/http-errors/node_modules/inherits/inherits_browser.js create mode 100644 node_modules/express/node_modules/send/node_modules/http-errors/node_modules/inherits/package.json create mode 100644 node_modules/express/node_modules/send/node_modules/http-errors/node_modules/inherits/test.js create mode 100644 node_modules/express/node_modules/send/node_modules/http-errors/package.json create mode 100644 node_modules/express/node_modules/send/node_modules/mime/.npmignore create mode 100644 node_modules/express/node_modules/send/node_modules/mime/LICENSE create mode 100644 node_modules/express/node_modules/send/node_modules/mime/README.md create mode 100644 node_modules/express/node_modules/send/node_modules/mime/build/build.js create mode 100644 node_modules/express/node_modules/send/node_modules/mime/build/test.js create mode 100755 node_modules/express/node_modules/send/node_modules/mime/cli.js create mode 100644 node_modules/express/node_modules/send/node_modules/mime/mime.js create mode 100644 node_modules/express/node_modules/send/node_modules/mime/package.json create mode 100644 node_modules/express/node_modules/send/node_modules/mime/types.json create mode 100644 node_modules/express/node_modules/send/node_modules/ms/.npmignore create mode 100644 node_modules/express/node_modules/send/node_modules/ms/LICENSE create mode 100644 node_modules/express/node_modules/send/node_modules/ms/README.md create mode 100644 node_modules/express/node_modules/send/node_modules/ms/index.js create mode 100644 node_modules/express/node_modules/send/node_modules/ms/package.json create mode 100644 node_modules/express/node_modules/send/node_modules/statuses/LICENSE create mode 100644 node_modules/express/node_modules/send/node_modules/statuses/README.md create mode 100644 node_modules/express/node_modules/send/node_modules/statuses/codes.json create mode 100644 node_modules/express/node_modules/send/node_modules/statuses/index.js create mode 100644 node_modules/express/node_modules/send/node_modules/statuses/package.json create mode 100644 node_modules/express/node_modules/send/package.json create mode 100644 node_modules/express/node_modules/serve-static/HISTORY.md create mode 100644 node_modules/express/node_modules/serve-static/LICENSE create mode 100644 node_modules/express/node_modules/serve-static/README.md create mode 100644 node_modules/express/node_modules/serve-static/index.js create mode 100644 node_modules/express/node_modules/serve-static/package.json create mode 100644 node_modules/express/node_modules/type-is/HISTORY.md create mode 100644 node_modules/express/node_modules/type-is/LICENSE create mode 100644 node_modules/express/node_modules/type-is/README.md create mode 100644 node_modules/express/node_modules/type-is/index.js create mode 100644 node_modules/express/node_modules/type-is/node_modules/media-typer/HISTORY.md create mode 100644 node_modules/express/node_modules/type-is/node_modules/media-typer/LICENSE create mode 100644 node_modules/express/node_modules/type-is/node_modules/media-typer/README.md create mode 100644 node_modules/express/node_modules/type-is/node_modules/media-typer/index.js create mode 100644 node_modules/express/node_modules/type-is/node_modules/media-typer/package.json create mode 100644 node_modules/express/node_modules/type-is/node_modules/mime-types/HISTORY.md create mode 100644 node_modules/express/node_modules/type-is/node_modules/mime-types/LICENSE create mode 100644 node_modules/express/node_modules/type-is/node_modules/mime-types/README.md create mode 100644 node_modules/express/node_modules/type-is/node_modules/mime-types/index.js create mode 100644 node_modules/express/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/HISTORY.md create mode 100644 node_modules/express/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/LICENSE create mode 100644 node_modules/express/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/README.md create mode 100644 node_modules/express/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/db.json create mode 100644 node_modules/express/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/index.js create mode 100644 node_modules/express/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/package.json create mode 100644 node_modules/express/node_modules/type-is/node_modules/mime-types/package.json create mode 100644 node_modules/express/node_modules/type-is/package.json create mode 100644 node_modules/express/node_modules/utils-merge/.travis.yml create mode 100644 node_modules/express/node_modules/utils-merge/LICENSE create mode 100644 node_modules/express/node_modules/utils-merge/README.md create mode 100644 node_modules/express/node_modules/utils-merge/index.js create mode 100644 node_modules/express/node_modules/utils-merge/package.json create mode 100644 node_modules/express/node_modules/vary/HISTORY.md create mode 100644 node_modules/express/node_modules/vary/LICENSE create mode 100644 node_modules/express/node_modules/vary/README.md create mode 100644 node_modules/express/node_modules/vary/index.js create mode 100644 node_modules/express/node_modules/vary/package.json create mode 100644 node_modules/express/package.json create mode 100644 package.json ~/heroku/hello-heroku $ heroku create whispering-lake-8767 ! Name is already taken ~/heroku/hello-heroku $ git push heroku master Counting objects: 298, done. Delta compression using up to 2 threads. Compressing objects: 100% (277/277), done. Writing objects: 100% (298/298), 279.54 KiB | 0 bytes/s, done. Total 298 (delta 41), reused 0 (delta 0) remote: Compressing source files... done. remote: Building source: remote: remote: -----> Node.js app detected remote: remote: -----> Creating runtime environment remote: remote: NPM_CONFIG_LOGLEVEL=error remote: NPM_CONFIG_PRODUCTION=true remote: NODE_MODULES_CACHE=true remote: remote: -----> Installing binaries remote: engines.node (package.json): 0.10.x remote: engines.npm (package.json): 1.4.x remote: remote: Resolving node version 0.10.x via semver.io... remote: Downloading and installing node 0.10.40... remote: Resolving npm version 1.4.x via semver.io... remote: npm 1.4.28 already installed with node remote: remote: -----> Restoring cache remote: Loading 1 from cacheDirectories (default): remote: - node_modules (exists - skipping) remote: remote: -----> Building dependencies remote: Prebuild detected (node_modules already exists) remote: Rebuilding any native modules remote: express@4.13.1 /tmp/build_43de9929d38da5c4dbc5d90d1788e976/node_modules/express remote: accepts@1.2.11 /tmp/build_43de9929d38da5c4dbc5d90d1788e976/node_modules/express/node_modules/accepts remote: mime-types@2.1.3 /tmp/build_43de9929d38da5c4dbc5d90d1788e976/node_modules/express/node_modules/accepts/node_modules/mime-types remote: mime-db@1.15.0 /tmp/build_43de9929d38da5c4dbc5d90d1788e976/node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db remote: negotiator@0.5.3 /tmp/build_43de9929d38da5c4dbc5d90d1788e976/node_modules/express/node_modules/accepts/node_modules/negotiator remote: array-flatten@1.1.0 /tmp/build_43de9929d38da5c4dbc5d90d1788e976/node_modules/express/node_modules/array-flatten remote: content-disposition@0.5.0 /tmp/build_43de9929d38da5c4dbc5d90d1788e976/node_modules/express/node_modules/content-disposition remote: content-type@1.0.1 /tmp/build_43de9929d38da5c4dbc5d90d1788e976/node_modules/express/node_modules/content-type remote: cookie@0.1.3 /tmp/build_43de9929d38da5c4dbc5d90d1788e976/node_modules/express/node_modules/cookie remote: cookie-signature@1.0.6 /tmp/build_43de9929d38da5c4dbc5d90d1788e976/node_modules/express/node_modules/cookie-signature remote: debug@2.2.0 /tmp/build_43de9929d38da5c4dbc5d90d1788e976/node_modules/express/node_modules/debug remote: ms@0.7.1 /tmp/build_43de9929d38da5c4dbc5d90d1788e976/node_modules/express/node_modules/debug/node_modules/ms remote: depd@1.0.1 /tmp/build_43de9929d38da5c4dbc5d90d1788e976/node_modules/express/node_modules/depd remote: escape-html@1.0.2 /tmp/build_43de9929d38da5c4dbc5d90d1788e976/node_modules/express/node_modules/escape-html remote: etag@1.7.0 /tmp/build_43de9929d38da5c4dbc5d90d1788e976/node_modules/express/node_modules/etag remote: finalhandler@0.4.0 /tmp/build_43de9929d38da5c4dbc5d90d1788e976/node_modules/express/node_modules/finalhandler remote: on-finished@2.3.0 /tmp/build_43de9929d38da5c4dbc5d90d1788e976/node_modules/express/node_modules/on-finished remote: ee-first@1.1.1 /tmp/build_43de9929d38da5c4dbc5d90d1788e976/node_modules/express/node_modules/on-finished/node_modules/ee-first remote: unpipe@1.0.0 /tmp/build_43de9929d38da5c4dbc5d90d1788e976/node_modules/express/node_modules/finalhandler/node_modules/unpipe remote: fresh@0.3.0 /tmp/build_43de9929d38da5c4dbc5d90d1788e976/node_modules/express/node_modules/fresh remote: merge-descriptors@1.0.0 /tmp/build_43de9929d38da5c4dbc5d90d1788e976/node_modules/express/node_modules/merge-descriptors remote: methods@1.1.1 /tmp/build_43de9929d38da5c4dbc5d90d1788e976/node_modules/express/node_modules/methods remote: parseurl@1.3.0 /tmp/build_43de9929d38da5c4dbc5d90d1788e976/node_modules/express/node_modules/parseurl remote: path-to-regexp@0.1.6 /tmp/build_43de9929d38da5c4dbc5d90d1788e976/node_modules/express/node_modules/path-to-regexp remote: proxy-addr@1.0.8 /tmp/build_43de9929d38da5c4dbc5d90d1788e976/node_modules/express/node_modules/proxy-addr remote: forwarded@0.1.0 /tmp/build_43de9929d38da5c4dbc5d90d1788e976/node_modules/express/node_modules/proxy-addr/node_modules/forwarded remote: ipaddr.js@1.0.1 /tmp/build_43de9929d38da5c4dbc5d90d1788e976/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js remote: qs@4.0.0 /tmp/build_43de9929d38da5c4dbc5d90d1788e976/node_modules/express/node_modules/qs remote: range-parser@1.0.2 /tmp/build_43de9929d38da5c4dbc5d90d1788e976/node_modules/express/node_modules/range-parser remote: send@0.13.0 /tmp/build_43de9929d38da5c4dbc5d90d1788e976/node_modules/express/node_modules/send remote: destroy@1.0.3 /tmp/build_43de9929d38da5c4dbc5d90d1788e976/node_modules/express/node_modules/send/node_modules/destroy remote: http-errors@1.3.1 /tmp/build_43de9929d38da5c4dbc5d90d1788e976/node_modules/express/node_modules/send/node_modules/http-errors remote: inherits@2.0.1 /tmp/build_43de9929d38da5c4dbc5d90d1788e976/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/inherits remote: statuses@1.2.1 /tmp/build_43de9929d38da5c4dbc5d90d1788e976/node_modules/express/node_modules/send/node_modules/statuses remote: mime@1.3.4 /tmp/build_43de9929d38da5c4dbc5d90d1788e976/node_modules/express/node_modules/send/node_modules/mime remote: ms@0.7.1 /tmp/build_43de9929d38da5c4dbc5d90d1788e976/node_modules/express/node_modules/send/node_modules/ms remote: serve-static@1.10.0 /tmp/build_43de9929d38da5c4dbc5d90d1788e976/node_modules/express/node_modules/serve-static remote: type-is@1.6.5 /tmp/build_43de9929d38da5c4dbc5d90d1788e976/node_modules/express/node_modules/type-is remote: media-typer@0.3.0 /tmp/build_43de9929d38da5c4dbc5d90d1788e976/node_modules/express/node_modules/type-is/node_modules/media-typer remote: mime-types@2.1.3 /tmp/build_43de9929d38da5c4dbc5d90d1788e976/node_modules/express/node_modules/type-is/node_modules/mime-types remote: mime-db@1.15.0 /tmp/build_43de9929d38da5c4dbc5d90d1788e976/node_modules/express/node_modules/type-is/node_modules/mime-types/node_modules/mime-db remote: vary@1.0.1 /tmp/build_43de9929d38da5c4dbc5d90d1788e976/node_modules/express/node_modules/vary remote: utils-merge@1.0.0 /tmp/build_43de9929d38da5c4dbc5d90d1788e976/node_modules/express/node_modules/utils-merge remote: Installing any new modules (package.json) remote: remote: -----> Caching build remote: Clearing previous node cache remote: Saving 1 cacheDirectories (default): remote: - node_modules remote: remote: -----> Build succeeded! remote: └── express@4.13.1 remote: remote: -----> Discovering process types remote: Procfile declares types -> web remote: remote: -----> Compressing... done, 6.1MB remote: -----> Launching... done, v3 remote: https://whispering-lake-8767.herokuapp.com/ deployed to Heroku remote: remote: Verifying deploy.... done. To https://git.heroku.com/whispering-lake-8767.git * [new branch] master -> master ~/heroku/hello-heroku $
ブラウザで見てみます。
無事に動作しているようです。
※1:「$ heroku create」だけを実行すると、適当な名前でアプリが作成されてしまうようです。リポジトリの名前との関係が今ひとつ理解できていません。
※2:上記の例ではFirefoxでURLを手打ちしましたが、「$ heroku open」でブラウザが開いてアプリを動かしてくれます。
13. メッセージを変えてみる
ソースファイルを以下の通り修正してみました。
var express = require("express"); var app = express(); //app.use(express.logger()); app.get('/', function(request, response) { response.send('Hello wonderful Heroku world!'); }) var port = process.env.PORT || 5000; app.listen(port, function() { console.log("Listening on " + port); });
herokuにアップロードして確認します。
~/heroku/hello-heroku $ git add . ~/heroku/hello-heroku $ git commit -m "2nd edition" [master 760e08d] 2nd edition 1 file changed, 1 insertion(+), 1 deletion(-) ~/heroku/hello-heroku $ git push heroku master Counting objects: 9, done. Delta compression using up to 2 threads. Compressing objects: 100% (7/7), done. Writing objects: 100% (7/7), 647 bytes | 0 bytes/s, done. Total 7 (delta 5), reused 0 (delta 0) remote: Compressing source files... done. remote: Building source: remote: remote: -----> Node.js app detected remote: remote: -----> Creating runtime environment remote: remote: NPM_CONFIG_LOGLEVEL=error remote: NPM_CONFIG_PRODUCTION=true remote: NODE_MODULES_CACHE=true remote: remote: -----> Installing binaries remote: engines.node (package.json): 0.10.x remote: engines.npm (package.json): 1.4.x remote: remote: Resolving node version 0.10.x via semver.io... remote: Downloading and installing node 0.10.40... remote: Resolving npm version 1.4.x via semver.io... remote: npm 1.4.28 already installed with node remote: remote: -----> Restoring cache remote: Loading 1 from cacheDirectories (default): remote: - node_modules (exists - skipping) remote: remote: -----> Building dependencies remote: Prebuild detected (node_modules already exists) remote: Rebuilding any native modules remote: express@4.13.1 /tmp/build_613eb4a9c27e30554a15fcbbb230a300/node_modules/express remote: accepts@1.2.11 /tmp/build_613eb4a9c27e30554a15fcbbb230a300/node_modules/express/node_modules/accepts remote: mime-types@2.1.3 /tmp/build_613eb4a9c27e30554a15fcbbb230a300/node_modules/express/node_modules/accepts/node_modules/mime-types remote: mime-db@1.15.0 /tmp/build_613eb4a9c27e30554a15fcbbb230a300/node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db remote: negotiator@0.5.3 /tmp/build_613eb4a9c27e30554a15fcbbb230a300/node_modules/express/node_modules/accepts/node_modules/negotiator remote: array-flatten@1.1.0 /tmp/build_613eb4a9c27e30554a15fcbbb230a300/node_modules/express/node_modules/array-flatten remote: content-disposition@0.5.0 /tmp/build_613eb4a9c27e30554a15fcbbb230a300/node_modules/express/node_modules/content-disposition remote: content-type@1.0.1 /tmp/build_613eb4a9c27e30554a15fcbbb230a300/node_modules/express/node_modules/content-type remote: cookie@0.1.3 /tmp/build_613eb4a9c27e30554a15fcbbb230a300/node_modules/express/node_modules/cookie remote: cookie-signature@1.0.6 /tmp/build_613eb4a9c27e30554a15fcbbb230a300/node_modules/express/node_modules/cookie-signature remote: debug@2.2.0 /tmp/build_613eb4a9c27e30554a15fcbbb230a300/node_modules/express/node_modules/debug remote: ms@0.7.1 /tmp/build_613eb4a9c27e30554a15fcbbb230a300/node_modules/express/node_modules/debug/node_modules/ms remote: depd@1.0.1 /tmp/build_613eb4a9c27e30554a15fcbbb230a300/node_modules/express/node_modules/depd remote: escape-html@1.0.2 /tmp/build_613eb4a9c27e30554a15fcbbb230a300/node_modules/express/node_modules/escape-html remote: etag@1.7.0 /tmp/build_613eb4a9c27e30554a15fcbbb230a300/node_modules/express/node_modules/etag remote: finalhandler@0.4.0 /tmp/build_613eb4a9c27e30554a15fcbbb230a300/node_modules/express/node_modules/finalhandler remote: on-finished@2.3.0 /tmp/build_613eb4a9c27e30554a15fcbbb230a300/node_modules/express/node_modules/on-finished remote: ee-first@1.1.1 /tmp/build_613eb4a9c27e30554a15fcbbb230a300/node_modules/express/node_modules/on-finished/node_modules/ee-first remote: unpipe@1.0.0 /tmp/build_613eb4a9c27e30554a15fcbbb230a300/node_modules/express/node_modules/finalhandler/node_modules/unpipe remote: fresh@0.3.0 /tmp/build_613eb4a9c27e30554a15fcbbb230a300/node_modules/express/node_modules/fresh remote: merge-descriptors@1.0.0 /tmp/build_613eb4a9c27e30554a15fcbbb230a300/node_modules/express/node_modules/merge-descriptors remote: methods@1.1.1 /tmp/build_613eb4a9c27e30554a15fcbbb230a300/node_modules/express/node_modules/methods remote: parseurl@1.3.0 /tmp/build_613eb4a9c27e30554a15fcbbb230a300/node_modules/express/node_modules/parseurl remote: path-to-regexp@0.1.6 /tmp/build_613eb4a9c27e30554a15fcbbb230a300/node_modules/express/node_modules/path-to-regexp remote: proxy-addr@1.0.8 /tmp/build_613eb4a9c27e30554a15fcbbb230a300/node_modules/express/node_modules/proxy-addr remote: forwarded@0.1.0 /tmp/build_613eb4a9c27e30554a15fcbbb230a300/node_modules/express/node_modules/proxy-addr/node_modules/forwarded remote: ipaddr.js@1.0.1 /tmp/build_613eb4a9c27e30554a15fcbbb230a300/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js remote: qs@4.0.0 /tmp/build_613eb4a9c27e30554a15fcbbb230a300/node_modules/express/node_modules/qs remote: range-parser@1.0.2 /tmp/build_613eb4a9c27e30554a15fcbbb230a300/node_modules/express/node_modules/range-parser remote: send@0.13.0 /tmp/build_613eb4a9c27e30554a15fcbbb230a300/node_modules/express/node_modules/send remote: destroy@1.0.3 /tmp/build_613eb4a9c27e30554a15fcbbb230a300/node_modules/express/node_modules/send/node_modules/destroy remote: http-errors@1.3.1 /tmp/build_613eb4a9c27e30554a15fcbbb230a300/node_modules/express/node_modules/send/node_modules/http-errors remote: inherits@2.0.1 /tmp/build_613eb4a9c27e30554a15fcbbb230a300/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/inherits remote: statuses@1.2.1 /tmp/build_613eb4a9c27e30554a15fcbbb230a300/node_modules/express/node_modules/send/node_modules/statuses remote: mime@1.3.4 /tmp/build_613eb4a9c27e30554a15fcbbb230a300/node_modules/express/node_modules/send/node_modules/mime remote: ms@0.7.1 /tmp/build_613eb4a9c27e30554a15fcbbb230a300/node_modules/express/node_modules/send/node_modules/ms remote: serve-static@1.10.0 /tmp/build_613eb4a9c27e30554a15fcbbb230a300/node_modules/express/node_modules/serve-static remote: type-is@1.6.5 /tmp/build_613eb4a9c27e30554a15fcbbb230a300/node_modules/express/node_modules/type-is remote: media-typer@0.3.0 /tmp/build_613eb4a9c27e30554a15fcbbb230a300/node_modules/express/node_modules/type-is/node_modules/media-typer remote: mime-types@2.1.3 /tmp/build_613eb4a9c27e30554a15fcbbb230a300/node_modules/express/node_modules/type-is/node_modules/mime-types remote: mime-db@1.15.0 /tmp/build_613eb4a9c27e30554a15fcbbb230a300/node_modules/express/node_modules/type-is/node_modules/mime-types/node_modules/mime-db remote: vary@1.0.1 /tmp/build_613eb4a9c27e30554a15fcbbb230a300/node_modules/express/node_modules/vary remote: utils-merge@1.0.0 /tmp/build_613eb4a9c27e30554a15fcbbb230a300/node_modules/express/node_modules/utils-merge remote: Installing any new modules (package.json) remote: remote: -----> Caching build remote: Clearing previous node cache remote: Saving 1 cacheDirectories (default): remote: - node_modules remote: remote: -----> Build succeeded! remote: └── express@4.13.1 remote: remote: -----> Discovering process types remote: Procfile declares types -> web remote: remote: -----> Compressing... done, 6.1MB remote: -----> Launching... done, v4 remote: https://whispering-lake-8767.herokuapp.com/ deployed to Heroku remote: remote: Verifying deploy.... done. To https://git.heroku.com/whispering-lake-8767.git ca0b038..760e08d master -> master ~/heroku/hello-heroku $ heroku open Opening whispering-lake-8767... done ~/heroku/hello-heroku $
ブラウザが開いて修正されたことが確認できます。