大家好,我认为在Heroku上部署我的节点应用程序会变得轻而易举,但结果却不那么容易。在部署了24个构建之后,我不知道我做错了什么。使用localhost运行我的应用程序:[port]工作正常,但是在Heroku上它并不是很棒。
我注意到当我使用命令git push heroku master
时,我看到我的节点包正在重新创建(?):
Building dependencies
remote: Prebuild detected (node_modules already exists)
remote: Rebuilding any native modules
remote: express@4.14.0 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/express
remote: accepts@1.3.3 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/accepts
remote: mime-types@2.1.11 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/mime-types
remote: mime-db@1.23.0 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/mime-db
remote: negotiator@0.6.1 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/negotiator
remote: array-flatten@1.1.1 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/array-flatten
remote: content-disposition@0.5.1 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/content-disposition
remote: content-type@1.0.2 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/content-type
remote: cookie@0.3.1 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/cookie
remote: cookie-signature@1.0.6 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/cookie-signature
remote: debug@2.2.0 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/debug
remote: ms@0.7.1 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/ms
remote: depd@1.1.0 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/depd
remote: encodeurl@1.0.1 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/encodeurl
remote: escape-html@1.0.3 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/escape-html
remote: etag@1.7.0 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/etag
remote: finalhandler@0.5.0 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/finalhandler
remote: on-finished@2.3.0 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/on-finished
remote: ee-first@1.1.1 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/ee-first
remote: statuses@1.3.0 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/statuses
remote: unpipe@1.0.0 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/unpipe
remote: fresh@0.3.0 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/fresh
remote: merge-descriptors@1.0.1 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/merge-descriptors
remote: methods@1.1.2 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/methods
remote: parseurl@1.3.1 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/parseurl
remote: path-to-regexp@0.1.7 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/path-to-regexp
remote: proxy-addr@1.1.2 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/proxy-addr
remote: forwarded@0.1.0 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/forwarded
remote: ipaddr.js@1.1.1 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/ipaddr.js
remote: qs@6.2.0 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/qs
remote: range-parser@1.2.0 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/range-parser
remote: send@0.14.1 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/express/node_modules/send
remote: destroy@1.0.4 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/destroy
remote: http-errors@1.5.0 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/http-errors
remote: inherits@2.0.1 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/inherits
remote: setprototypeof@1.0.1 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/setprototypeof
remote: mime@1.3.4 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/mime
remote: serve-static@1.11.1 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/serve-static
remote: send@0.14.1 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/send
remote: type-is@1.6.13 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/type-is
remote: media-typer@0.3.0 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/media-typer
remote: utils-merge@1.0.0 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/utils-merge
remote: vary@1.1.0 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/vary
remote: jade@1.11.0 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/jade
remote: character-parser@1.2.1 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/character-parser
remote: clean-css@3.4.18 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/clean-css
remote: commander@2.8.1 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/clean-css/node_modules/commander
remote: graceful-readlink@1.0.1 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/graceful-readlink
remote: source-map@0.4.4 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/source-map
remote: amdefine@1.0.0 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/amdefine
remote: commander@2.6.0 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/commander
remote: constantinople@3.0.2 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/constantinople
remote: acorn@2.7.0 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/acorn
remote: jstransformer@0.0.2 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/jstransformer
remote: is-promise@2.1.0 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/is-promise
remote: promise@6.1.0 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/promise
remote: asap@1.0.0 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/asap
remote: mkdirp@0.5.1 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/mkdirp
remote: minimist@0.0.8 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/minimist
remote: transformers@2.1.0 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/transformers
remote: css@1.0.8 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/css
remote: css-parse@1.0.4 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/css-parse
remote: css-stringify@1.0.5 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/css-stringify
remote: promise@2.0.0 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/transformers/node_modules/promise
remote: is-promise@1.0.1 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/transformers/node_modules/is-promise
remote: uglify-js@2.2.5 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/transformers/node_modules/uglify-js
remote: optimist@0.3.7 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/optimist
remote: wordwrap@0.0.3 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/wordwrap
remote: source-map@0.1.43 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/transformers/node_modules/source-map
remote: uglify-js@2.6.4 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/uglify-js
remote: async@0.2.10 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/async
remote: source-map@0.5.6 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/uglify-js/node_modules/source-map
remote: uglify-to-browserify@1.0.2 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/uglify-to-browserify
remote: yargs@3.10.0 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/yargs
remote: camelcase@1.2.1 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/camelcase
remote: cliui@2.1.0 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/cliui
remote: center-align@0.1.3 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/center-align
remote: align-text@0.1.4 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/align-text
remote: kind-of@3.0.3 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/kind-of
remote: is-buffer@1.1.3 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/is-buffer
remote: longest@1.0.1 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/longest
remote: repeat-string@1.5.4 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/repeat-string
remote: lazy-cache@1.0.4 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/lazy-cache
remote: right-align@0.1.3 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/right-align
remote: wordwrap@0.0.2 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/cliui/node_modules/wordwrap
remote: decamelize@1.2.0 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/decamelize
remote: window-size@0.1.0 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/window-size
remote: void-elements@2.0.1 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/void-elements
remote: with@4.0.3 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/with
remote: acorn@1.2.2 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/with/node_modules/acorn
remote: acorn-globals@1.0.9 /tmp/build_a769e7fce1f5ff3a3dbd69d44125be90/node_modules/acorn-globals
remote: Installing any new modules (package.json)
remote:
我为那段巨大的文字道歉,但据我所知,你所看到的是我的node_modules
文件夹中的所有节点模块都因某种原因被重新创建。但在此之后,构建成功并准备好使用。
因此,当我运行命令heroku ps:scale web=1
时,我收到消息Scaling dynos... done, now running web at 1:Free
。到目前为止一切都很好,但是当我实际打开我的应用程序时出现应用程序错误,所以我输入heroku logs -n 52
因为我已经这么多次这样做了,我知道有多少行与我有关。但这是给我的回复:
2016-06-23T23:02:31.826487+00:00 heroku[web.1]: State changed from starting to crashed
2016-06-23T23:04:08.293203+00:00 heroku[api]: Release v24 created by mauricecunningham@ymail.com
2016-06-23T23:04:08.293113+00:00 heroku[api]: Deploy a4025b7 by mauricecunningham@ymail.com
2016-06-23T23:04:08.501758+00:00 heroku[slug-compiler]: Slug compilation started
2016-06-23T23:04:08.501767+00:00 heroku[slug-compiler]: Slug compilation finished
2016-06-23T23:04:08.465484+00:00 heroku[web.1]: State changed from crashed to starting
2016-06-23T23:04:12.635495+00:00 heroku[web.1]: Starting process with command `npm start`
2016-06-23T23:04:15.429410+00:00 app[web.1]:
2016-06-23T23:04:15.429425+00:00 app[web.1]: > abcusd@1.0.0 start /app
2016-06-23T23:04:15.429431+00:00 app[web.1]: > node src/app.js
2016-06-23T23:04:15.429432+00:00 app[web.1]:
2016-06-23T23:04:15.639033+00:00 app[web.1]: module.js:327
2016-06-23T23:04:15.639043+00:00 app[web.1]: throw err;
2016-06-23T23:04:15.639043+00:00 app[web.1]: ^
2016-06-23T23:04:15.639059+00:00 app[web.1]: Error: Cannot find module './mock/test.json'
2016-06-23T23:04:15.639057+00:00 app[web.1]:
2016-06-23T23:04:15.639060+00:00 app[web.1]: at Function.Module._load (module.js:276:25)
2016-06-23T23:04:15.639061+00:00 app[web.1]: at Module.require (module.js:353:17)
2016-06-23T23:04:15.639060+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:325:15)
2016-06-23T23:04:15.639062+00:00 app[web.1]: at require (internal/module.js:12:17)
2016-06-23T23:04:15.639062+00:00 app[web.1]: at Object.<anonymous> (/app/src/app.js:4:19)
2016-06-23T23:04:15.639063+00:00 app[web.1]: at Module._compile (module.js:409:26)
2016-06-23T23:04:15.639065+00:00 app[web.1]: at Function.Module._load (module.js:300:12)
2016-06-23T23:04:15.639063+00:00 app[web.1]: at Object.Module._extensions..js (module.js:416:10)
2016-06-23T23:04:15.639064+00:00 app[web.1]: at Module.load (module.js:343:32)
2016-06-23T23:04:15.654257+00:00 app[web.1]: npm ERR! node v4.4.5
2016-06-23T23:04:15.653958+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2016-06-23T23:04:15.653512+00:00 app[web.1]: npm ERR! Linux 3.13.0-85-generic
2016-06-23T23:04:15.639065+00:00 app[web.1]: at Function.Module.runMain (module.js:441:10)
2016-06-23T23:04:15.646563+00:00 app[web.1]:
2016-06-23T23:04:15.655142+00:00 app[web.1]: npm ERR! npm v2.15.5
2016-06-23T23:04:15.656197+00:00 app[web.1]: npm ERR! This is most likely a problem with the abcusd package,
2016-06-23T23:04:15.655683+00:00 app[web.1]: npm ERR! Exit status 1
2016-06-23T23:04:15.656034+00:00 app[web.1]: npm ERR! Failed at the abcusd@1.0.0 start script 'node src/app.js'.
2016-06-23T23:04:15.655527+00:00 app[web.1]: npm ERR! abcusd@1.0.0 start: `node src/app.js`
2016-06-23T23:04:15.655890+00:00 app[web.1]: npm ERR!
2016-06-23T23:04:15.656507+00:00 app[web.1]: npm ERR! Tell the author that this fails on your system:
2016-06-23T23:04:15.656352+00:00 app[web.1]: npm ERR! not with npm itself.
2016-06-23T23:04:15.656663+00:00 app[web.1]: npm ERR! node src/app.js
2016-06-23T23:04:15.656813+00:00 app[web.1]: npm ERR! You can get information on how to open an issue for this project with:
2016-06-23T23:04:15.657050+00:00 app[web.1]: npm ERR! npm bugs abcusd
2016-06-23T23:04:15.655368+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2016-06-23T23:04:15.657292+00:00 app[web.1]: npm ERR!
2016-06-23T23:04:15.657124+00:00 app[web.1]: npm ERR! Or if that isn't available, you can get their info via:
2016-06-23T23:04:15.657430+00:00 app[web.1]: npm ERR! npm owner ls abcusd
2016-06-23T23:04:15.657611+00:00 app[web.1]: npm ERR! There is likely additional logging output above.
2016-06-23T23:04:15.660924+00:00 app[web.1]:
2016-06-23T23:04:15.661300+00:00 app[web.1]: npm ERR! /app/npm-debug.log
2016-06-23T23:04:15.661148+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2016-06-23T23:04:16.484660+00:00 heroku[web.1]: State changed from starting to crashed
2016-06-23T23:04:16.476664+00:00 heroku[web.1]: Process exited with status 1
2016-06-23T23:04:24.383512+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=abcusd.herokuapp.com request_id=c782e08e-5862-4ae2-89ab-26d2c52aba1b fwd="99.6.116.10" dyno= connect= service= status=503 bytes=
2016-06-23T23:04:24.784780+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=abcusd.herokuapp.com request_id=93241ada-ddfa-4356-9d1f-e6809ee8ef6c fwd="99.6.116.10" dyno= connect= service= status=503 bytes=
我最感兴趣的部分是:Error: Cannot find module './mock/test.json'
这只是对json文件的引用,该文件在呈现时向我的页面提供数据,据我所知,不是模块,与节点模块被视为模块的方式相同。我认为当重新创建模块时,我的json文件被搞砸了,但这只是猜测。我究竟做错了什么?
干杯
编辑 - 包括package.json
{
"name": "abcusd",
"version": "1.0.0",
"description": "special education website",
"main": "ABCUSD/",
"engines": {
"node": "^4.4.2"
},
"scripts": {
"start": "node src/app.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/m00se333/ABCUSD.git"
},
"author": "Maurice Cunningham",
"license": "MIT",
"bugs": {
"url": "https://github.com/m00se333/ABCUSD/issues"
},
"homepage": "https://github.com/m00se333/ABCUSD#readme",
"dependencies": {
"express": "^4.14.0",
"jade": "^1.11.0"
}
}
答案 0 :(得分:0)
看起来你的一个源文件需要./mock/test.json,但它不在git中,因此不会上传到heroku。
此实例中的模块是节点的Module.js,用于处理require调用。给出失败的路径这与node_modules无关。