Node.js 为什么我的Heroku日志中没有错误?内部服务器错误
我正在做我的第一个node.js项目,并且正在使用把手进行模板制作。 当我今天通过Heroku部署时,出现了500个错误,在日志中似乎找不到任何东西。在本地一切正常。 我第一次设置了一个新的助手,所以我认为这与此相关。 我将在下面发布我的app.js和日志代码。谢谢Node.js 为什么我的Heroku日志中没有错误?内部服务器错误,node.js,express,heroku,handlebars.js,http-status-code-500,Node.js,Express,Heroku,Handlebars.js,Http Status Code 500,我正在做我的第一个node.js项目,并且正在使用把手进行模板制作。 当我今天通过Heroku部署时,出现了500个错误,在日志中似乎找不到任何东西。在本地一切正常。 我第一次设置了一个新的助手,所以我认为这与此相关。 我将在下面发布我的app.js和日志代码。谢谢 const express = require('express') const app = express() const exphbs = require('express-handlebars'); const path =
const express = require('express')
const app = express()
const exphbs = require('express-handlebars');
const path = require('path');
const request = require("request");
const bodyParser = require('body-parser');
const PORT = process.env.PORT || 5000;
const hbs = exphbs.create({
//create custom helpers here
helpers:{
negPosChange: function(value, options){
if(value > 0) {
return "<div class=\"positive\">+" + options.fn({test: value}) + "</div>";
}
else if(value < 0){
return "<div class=\"negative\">" + options.fn({test: value}) + "</div>";
}
else{
return "<div>" + options.fn({test: value}) + "</div>";
}
}
}
});
// use body parser middleware -- using express instead for now
app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json())
// create call API function
function call_api(finishedAPI, ticker){
request('https://cloud.iexapis.com/stable/stock/' + ticker + '/quote?token=#APIKEY', function (err, res, body) {
if (err) {return console.log(err);}
if(res.statusCode === 200){
//console.log(body);
finishedAPI(JSON.parse(body));
}
});
}
//Set handlebars middleware
app.engine('handlebars', hbs.engine);
app.set('view engine', 'handlebars');
//Set handlebar index GET route
app.get('/ticker_page.html', function (req, res) {
call_api(function(doneAPI){
res.render('ticker_page', {
stock: doneAPI
});
}, 'fb');
});
//Set handlebar index POST route
app.post('/', function (req, res) {
call_api(function(doneAPI){
//posted_stuff = req.body.stock_search;
res.render('ticker_page', {
stock: doneAPI,
});
}, req.body.stock_search.toLowerCase().trim());
});
//Create about page route
app.get('/about.html', function (req, res) {
res.render('about');
});
//Create about page route
app.get('/', function (req, res) {
res.render('home/home', {layout : 'home-template'});
});
// Set static folder
app.use(express.static(path.join(__dirname, '/')));
app.listen(PORT, () => console.log('Server listening on port' + PORT));
-----> Building on the Heroku-20 stack
-----> Using buildpack: heroku/nodejs
-----> Node.js app detected
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NODE_VERBOSE=false
NODE_ENV=production
NODE_MODULES_CACHE=true
-----> Installing binaries
engines.node (package.json): unspecified
engines.npm (package.json): unspecified (use default)
Resolving node version 14.x...
Downloading and installing node 14.16.1...
Using default npm version: 6.14.12
-----> Restoring cache
- node_modules is checked into source control and cannot be cached
-----> Installing dependencies
Prebuild detected (node_modules already exists)
Rebuilding any native modules
> nodemon@2.0.7 postinstall /tmp/build_b3975c7b/node_modules/nodemon
> node bin/postinstall || exit 0
Love nodemon? You can now support the project via the open collective:
> https://opencollective.com/nodemon/donate
body-parser@1.19.0 /tmp/build_b3975c7b/node_modules/body-parser
bytes@3.1.0 /tmp/build_b3975c7b/node_modules/bytes
content-type@1.0.4 /tmp/build_b3975c7b/node_modules/content-type
debug@2.6.9 /tmp/build_b3975c7b/node_modules/debug
ms@2.0.0 /tmp/build_b3975c7b/node_modules/ms
depd@1.1.2 /tmp/build_b3975c7b/node_modules/depd
http-errors@1.7.2 /tmp/build_b3975c7b/node_modules/http-errors
inherits@2.0.3 /tmp/build_b3975c7b/node_modules/inherits
setprototypeof@1.1.1 /tmp/build_b3975c7b/node_modules/setprototypeof
statuses@1.5.0 /tmp/build_b3975c7b/node_modules/statuses
toidentifier@1.0.0 /tmp/build_b3975c7b/node_modules/toidentifier
iconv-lite@0.4.24 /tmp/build_b3975c7b/node_modules/iconv-lite
safer-buffer@2.1.2 /tmp/build_b3975c7b/node_modules/safer-buffer
on-finished@2.3.0 /tmp/build_b3975c7b/node_modules/on-finished
ee-first@1.1.1 /tmp/build_b3975c7b/node_modules/ee-first
qs@6.7.0 /tmp/build_b3975c7b/node_modules/qs
raw-body@2.4.0 /tmp/build_b3975c7b/node_modules/raw-body
unpipe@1.0.0 /tmp/build_b3975c7b/node_modules/unpipe
type-is@1.6.18 /tmp/build_b3975c7b/node_modules/type-is
media-typer@0.3.0 /tmp/build_b3975c7b/node_modules/media-typer
mime-types@2.1.30 /tmp/build_b3975c7b/node_modules/mime-types
mime-db@1.47.0 /tmp/build_b3975c7b/node_modules/mime-db
express@4.17.1 /tmp/build_b3975c7b/node_modules/express
accepts@1.3.7 /tmp/build_b3975c7b/node_modules/accepts
negotiator@0.6.2 /tmp/build_b3975c7b/node_modules/negotiator
array-flatten@1.1.1 /tmp/build_b3975c7b/node_modules/array-flatten
content-disposition@0.5.3 /tmp/build_b3975c7b/node_modules/content-disposition
safe-buffer@5.1.2 /tmp/build_b3975c7b/node_modules/safe-buffer
cookie@0.4.0 /tmp/build_b3975c7b/node_modules/cookie
cookie-signature@1.0.6 /tmp/build_b3975c7b/node_modules/cookie-signature
encodeurl@1.0.2 /tmp/build_b3975c7b/node_modules/encodeurl
escape-html@1.0.3 /tmp/build_b3975c7b/node_modules/escape-html
etag@1.8.1 /tmp/build_b3975c7b/node_modules/etag
finalhandler@1.1.2 /tmp/build_b3975c7b/node_modules/finalhandler
parseurl@1.3.3 /tmp/build_b3975c7b/node_modules/parseurl
fresh@0.5.2 /tmp/build_b3975c7b/node_modules/fresh
merge-descriptors@1.0.1 /tmp/build_b3975c7b/node_modules/merge-descriptors
methods@1.1.2 /tmp/build_b3975c7b/node_modules/methods
path-to-regexp@0.1.7 /tmp/build_b3975c7b/node_modules/path-to-regexp
proxy-addr@2.0.6 /tmp/build_b3975c7b/node_modules/proxy-addr
forwarded@0.1.2 /tmp/build_b3975c7b/node_modules/forwarded
ipaddr.js@1.9.1 /tmp/build_b3975c7b/node_modules/ipaddr.js
range-parser@1.2.1 /tmp/build_b3975c7b/node_modules/range-parser
send@0.17.1 /tmp/build_b3975c7b/node_modules/send
destroy@1.0.4 /tmp/build_b3975c7b/node_modules/destroy
mime@1.6.0 /tmp/build_b3975c7b/node_modules/mime
ms@2.1.1 /tmp/build_b3975c7b/node_modules/send/node_modules/ms
serve-static@1.14.1 /tmp/build_b3975c7b/node_modules/serve-static
utils-merge@1.0.1 /tmp/build_b3975c7b/node_modules/utils-merge
vary@1.1.2 /tmp/build_b3975c7b/node_modules/vary
express-handlebars@5.3.0 /tmp/build_b3975c7b/node_modules/express-handlebars
glob@7.1.6 /tmp/build_b3975c7b/node_modules/glob
fs.realpath@1.0.0 /tmp/build_b3975c7b/node_modules/fs.realpath
inflight@1.0.6 /tmp/build_b3975c7b/node_modules/inflight
once@1.4.0 /tmp/build_b3975c7b/node_modules/once
wrappy@1.0.2 /tmp/build_b3975c7b/node_modules/wrappy
minimatch@3.0.4 /tmp/build_b3975c7b/node_modules/minimatch
brace-expansion@1.1.11 /tmp/build_b3975c7b/node_modules/brace-expansion
balanced-match@1.0.2 /tmp/build_b3975c7b/node_modules/balanced-match
concat-map@0.0.1 /tmp/build_b3975c7b/node_modules/concat-map
path-is-absolute@1.0.1 /tmp/build_b3975c7b/node_modules/path-is-absolute
graceful-fs@4.2.6 /tmp/build_b3975c7b/node_modules/graceful-fs
handlebars@4.7.7 /tmp/build_b3975c7b/node_modules/handlebars
minimist@1.2.5 /tmp/build_b3975c7b/node_modules/minimist
neo-async@2.6.2 /tmp/build_b3975c7b/node_modules/neo-async
source-map@0.6.1 /tmp/build_b3975c7b/node_modules/source-map
wordwrap@1.0.0 /tmp/build_b3975c7b/node_modules/wordwrap
@sindresorhus/is@0.14.0 /tmp/build_b3975c7b/node_modules/@sindresorhus/is
@szmarczak/http-timer@1.1.2 /tmp/build_b3975c7b/node_modules/@szmarczak/http-timer
defer-to-connect@1.1.3 /tmp/build_b3975c7b/node_modules/defer-to-connect
abbrev@1.1.1 /tmp/build_b3975c7b/node_modules/abbrev
ansi-regex@4.1.0 /tmp/build_b3975c7b/node_modules/ansi-regex
ansi-styles@4.3.0 /tmp/build_b3975c7b/node_modules/ansi-styles
color-convert@2.0.1 /tmp/build_b3975c7b/node_modules/color-convert
color-name@1.1.4 /tmp/build_b3975c7b/node_modules/color-name
anymatch@3.1.2 /tmp/build_b3975c7b/node_modules/anymatch
normalize-path@3.0.0 /tmp/build_b3975c7b/node_modules/normalize-path
picomatch@2.2.3 /tmp/build_b3975c7b/node_modules/picomatch
binary-extensions@2.2.0 /tmp/build_b3975c7b/node_modules/binary-extensions
boxen@4.2.0 /tmp/build_b3975c7b/node_modules/boxen
ansi-align@3.0.0 /tmp/build_b3975c7b/node_modules/ansi-align
string-width@3.1.0 /tmp/build_b3975c7b/node_modules/ansi-align/node_modules/string-width
emoji-regex@7.0.3 /tmp/build_b3975c7b/node_modules/emoji-regex
is-fullwidth-code-point@2.0.0 /tmp/build_b3975c7b/node_modules/is-fullwidth-code-point
strip-ansi@5.2.0 /tmp/build_b3975c7b/node_modules/strip-ansi
camelcase@5.3.1 /tmp/build_b3975c7b/node_modules/camelcase
chalk@3.0.0 /tmp/build_b3975c7b/node_modules/chalk
supports-color@7.2.0 /tmp/build_b3975c7b/node_modules/chalk/node_modules/supports-color
has-flag@4.0.0 /tmp/build_b3975c7b/node_modules/chalk/node_modules/has-flag
cli-boxes@2.2.1 /tmp/build_b3975c7b/node_modules/cli-boxes
string-width@4.2.2 /tmp/build_b3975c7b/node_modules/string-width
emoji-regex@8.0.0 /tmp/build_b3975c7b/node_modules/string-width/node_modules/emoji-regex
is-fullwidth-code-point@3.0.0 /tmp/build_b3975c7b/node_modules/string-width/node_modules/is-fullwidth-code-point
strip-ansi@6.0.0 /tmp/build_b3975c7b/node_modules/string-width/node_modules/strip-ansi
ansi-regex@5.0.0 /tmp/build_b3975c7b/node_modules/string-width/node_modules/ansi-regex
term-size@2.2.1 /tmp/build_b3975c7b/node_modules/term-size
type-fest@0.8.1 /tmp/build_b3975c7b/node_modules/type-fest
widest-line@3.1.0 /tmp/build_b3975c7b/node_modules/widest-line
braces@3.0.2 /tmp/build_b3975c7b/node_modules/braces
fill-range@7.0.1 /tmp/build_b3975c7b/node_modules/fill-range
to-regex-range@5.0.1 /tmp/build_b3975c7b/node_modules/to-regex-range
is-number@7.0.0 /tmp/build_b3975c7b/node_modules/is-number
chokidar@3.5.1 /tmp/build_b3975c7b/node_modules/chokidar
glob-parent@5.1.2 /tmp/build_b3975c7b/node_modules/glob-parent
is-glob@4.0.1 /tmp/build_b3975c7b/node_modules/is-glob
is-extglob@2.1.1 /tmp/build_b3975c7b/node_modules/is-extglob
is-binary-path@2.1.0 /tmp/build_b3975c7b/node_modules/is-binary-path
readdirp@3.5.0 /tmp/build_b3975c7b/node_modules/readdirp
ci-info@2.0.0 /tmp/build_b3975c7b/node_modules/ci-info
clone-response@1.0.2 /tmp/build_b3975c7b/node_modules/clone-response
mimic-response@1.0.1 /tmp/build_b3975c7b/node_modules/mimic-response
configstore@5.0.1 /tmp/build_b3975c7b/node_modules/configstore
dot-prop@5.3.0 /tmp/build_b3975c7b/node_modules/dot-prop
is-obj@2.0.0 /tmp/build_b3975c7b/node_modules/is-obj
make-dir@3.1.0 /tmp/build_b3975c7b/node_modules/make-dir
semver@6.3.0 /tmp/build_b3975c7b/node_modules/make-dir/node_modules/semver
unique-string@2.0.0 /tmp/build_b3975c7b/node_modules/unique-string
crypto-random-string@2.0.0 /tmp/build_b3975c7b/node_modules/crypto-random-string
write-file-atomic@3.0.3 /tmp/build_b3975c7b/node_modules/write-file-atomic
imurmurhash@0.1.4 /tmp/build_b3975c7b/node_modules/imurmurhash
is-typedarray@1.0.0 /tmp/build_b3975c7b/node_modules/is-typedarray
signal-exit@3.0.3 /tmp/build_b3975c7b/node_modules/signal-exit
typedarray-to-buffer@3.1.5 /tmp/build_b3975c7b/node_modules/typedarray-to-buffer
xdg-basedir@4.0.0 /tmp/build_b3975c7b/node_modules/xdg-basedir
decompress-response@3.3.0 /tmp/build_b3975c7b/node_modules/decompress-response
deep-extend@0.6.0 /tmp/build_b3975c7b/node_modules/deep-extend
duplexer3@0.1.4 /tmp/build_b3975c7b/node_modules/duplexer3
end-of-stream@1.4.4 /tmp/build_b3975c7b/node_modules/end-of-stream
escape-goat@2.1.1 /tmp/build_b3975c7b/node_modules/escape-goat
get-stream@4.1.0 /tmp/build_b3975c7b/node_modules/get-stream
pump@3.0.0 /tmp/build_b3975c7b/node_modules/pump
global-dirs@2.1.0 /tmp/build_b3975c7b/node_modules/global-dirs
ini@1.3.7 /tmp/build_b3975c7b/node_modules/ini
got@9.6.0 /tmp/build_b3975c7b/node_modules/got
cacheable-request@6.1.0 /tmp/build_b3975c7b/node_modules/cacheable-request
get-stream@5.2.0 /tmp/build_b3975c7b/node_modules/cacheable-request/node_modules/get-stream
http-cache-semantics@4.1.0 /tmp/build_b3975c7b/node_modules/http-cache-semantics
keyv@3.1.0 /tmp/build_b3975c7b/node_modules/keyv
json-buffer@3.0.0 /tmp/build_b3975c7b/node_modules/json-buffer
lowercase-keys@2.0.0 /tmp/build_b3975c7b/node_modules/cacheable-request/node_modules/lowercase-keys
normalize-url@4.5.0 /tmp/build_b3975c7b/node_modules/normalize-url
responselike@1.0.2 /tmp/build_b3975c7b/node_modules/responselike
lowercase-keys@1.0.1 /tmp/build_b3975c7b/node_modules/lowercase-keys
p-cancelable@1.1.0 /tmp/build_b3975c7b/node_modules/p-cancelable
to-readable-stream@1.0.0 /tmp/build_b3975c7b/node_modules/to-readable-stream
url-parse-lax@3.0.0 /tmp/build_b3975c7b/node_modules/url-parse-lax
prepend-http@2.0.0 /tmp/build_b3975c7b/node_modules/prepend-http
has-flag@3.0.0 /tmp/build_b3975c7b/node_modules/has-flag
has-yarn@2.1.0 /tmp/build_b3975c7b/node_modules/has-yarn
ignore-by-default@1.0.1 /tmp/build_b3975c7b/node_modules/ignore-by-default
import-lazy@2.1.0 /tmp/build_b3975c7b/node_modules/import-lazy
is-installed-globally@0.3.2 /tmp/build_b3975c7b/node_modules/is-installed-globally
is-path-inside@3.0.3 /tmp/build_b3975c7b/node_modules/is-path-inside
is-npm@4.0.0 /tmp/build_b3975c7b/node_modules/is-npm
is-yarn-global@0.3.0 /tmp/build_b3975c7b/node_modules/is-yarn-global
latest-version@5.1.0 /tmp/build_b3975c7b/node_modules/latest-version
package-json@6.5.0 /tmp/build_b3975c7b/node_modules/package-json
registry-auth-token@4.2.1 /tmp/build_b3975c7b/node_modules/registry-auth-token
rc@1.2.8 /tmp/build_b3975c7b/node_modules/rc
strip-json-comments@2.0.1 /tmp/build_b3975c7b/node_modules/strip-json-comments
registry-url@5.1.0 /tmp/build_b3975c7b/node_modules/registry-url
semver@6.3.0 /tmp/build_b3975c7b/node_modules/package-json/node_modules/semver
pstree.remy@1.1.8 /tmp/build_b3975c7b/node_modules/pstree.remy
pupa@2.1.1 /tmp/build_b3975c7b/node_modules/pupa
supports-color@5.5.0 /tmp/build_b3975c7b/node_modules/supports-color
undefsafe@2.0.3 /tmp/build_b3975c7b/node_modules/undefsafe
update-notifier@4.1.3 /tmp/build_b3975c7b/node_modules/update-notifier
is-ci@2.0.0 /tmp/build_b3975c7b/node_modules/is-ci
semver-diff@3.1.1 /tmp/build_b3975c7b/node_modules/semver-diff
semver@6.3.0 /tmp/build_b3975c7b/node_modules/semver-diff/node_modules/semver
nopt@1.0.10 /tmp/build_b3975c7b/node_modules/nopt
semver@5.7.1 /tmp/build_b3975c7b/node_modules/semver
touch@3.1.0 /tmp/build_b3975c7b/node_modules/touch
uglify-js@3.13.5 /tmp/build_b3975c7b/node_modules/uglify-js
nodemon@2.0.7 /tmp/build_b3975c7b/node_modules/nodemon
debug@3.2.7 /tmp/build_b3975c7b/node_modules/nodemon/node_modules/debug
ms@2.1.3 /tmp/build_b3975c7b/node_modules/nodemon/node_modules/ms
Installing any new modules (package.json)
> node-sass@4.14.1 install /tmp/build_b3975c7b/node_modules/gulp-sass/node_modules/node-sass
> node scripts/install.js
Downloading binary from https://github.com/sass/node-sass/releases/download/v4.14.1/linux-x64-83_binding.node
Download complete
Binary saved to /tmp/build_b3975c7b/node_modules/gulp-sass/node_modules/node-sass/vendor/linux-x64-83/binding.node
Caching binary to /tmp/npmcache.wd8xU/node-sass/4.14.1/linux-x64-83_binding.node
> node-sass@5.0.0 install /tmp/build_b3975c7b/node_modules/node-sass
> node scripts/install.js
Downloading binary from https://github.com/sass/node-sass/releases/download/v5.0.0/linux-x64-83_binding.node
Download complete
Binary saved to /tmp/build_b3975c7b/node_modules/node-sass/vendor/linux-x64-83/binding.node
Caching binary to /tmp/npmcache.wd8xU/node-sass/5.0.0/linux-x64-83_binding.node
> highlight.js@9.18.5 postinstall /tmp/build_b3975c7b/node_modules/highlight.js
> node deprecated.js
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Verion 9 of Highlight.js has reached EOL. It will no longer
be supported or receive security updates in the future.
Please upgrade to version 10 or encourage your indirect
dependencies to do so.
For more info:
https://github.com/highlightjs/highlight.js/issues/2877
https://github.com/highlightjs/highlight.js/blob/master/VERSION_10_UPGRADE.md
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
> node-sass@4.14.1 postinstall /tmp/build_b3975c7b/node_modules/gulp-sass/node_modules/node-sass
> node scripts/build.js
Binary found at /tmp/build_b3975c7b/node_modules/gulp-sass/node_modules/node-sass/vendor/linux-x64-83/binding.node
Testing binary
Binary is fine
> node-sass@5.0.0 postinstall /tmp/build_b3975c7b/node_modules/node-sass
> node scripts/build.js
Binary found at /tmp/build_b3975c7b/node_modules/node-sass/vendor/linux-x64-83/binding.node
Testing binary
Binary is fine
added 572 packages from 652 contributors and audited 751 packages in 17.707s
22 packages are looking for funding
run `npm fund` for details
found 1 low severity vulnerability
run `npm audit fix` to fix them, or `npm audit` for details
-----> Build
-----> Caching build
- node_modules
-----> Pruning devDependencies
removed 429 packages and audited 320 packages in 6.66s
2 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
-----> Build succeeded!