我正在尝试在heroku中部署Nodejs应用程序,但它一直告诉我“应用程序错误”

时间:2020-10-04 22:59:49

标签: node.js heroku

我有这个仓库,我是从另一个假定可以工作的仓库中分叉的,即插即用。但是,当我部署它时,它将返回应用程序错误。我已经解决了所有npm漏洞。

血球记录如下

    -----> Node.js app detected
       
-----> Creating runtime environment
       
       NPM_CONFIG_LOGLEVEL=error
       NODE_ENV=production
       NODE_MODULES_CACHE=true
       NODE_VERBOSE=false
       
-----> Installing binaries
       engines.node (package.json):  unspecified
       engines.npm (package.json):   unspecified (use default)
       
       Resolving node version 12.x...
       Downloading and installing node 12.18.4...
       Using default npm version: 6.14.6
       
-----> 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
       express-handlebars@3.1.0 /tmp/build_514cee29_/node_modules/express-handlebars
       glob@7.1.4 /tmp/build_514cee29_/node_modules/glob
       fs.realpath@1.0.0 /tmp/build_514cee29_/node_modules/fs.realpath
       inflight@1.0.6 /tmp/build_514cee29_/node_modules/inflight
       once@1.4.0 /tmp/build_514cee29_/node_modules/once
       wrappy@1.0.2 /tmp/build_514cee29_/node_modules/wrappy
       inherits@2.0.4 /tmp/build_514cee29_/node_modules/inherits
       minimatch@3.0.4 /tmp/build_514cee29_/node_modules/minimatch
       brace-expansion@1.1.11 /tmp/build_514cee29_/node_modules/brace-expansion
       balanced-match@1.0.0 /tmp/build_514cee29_/node_modules/balanced-match
       concat-map@0.0.1 /tmp/build_514cee29_/node_modules/concat-map
       path-is-absolute@1.0.1 /tmp/build_514cee29_/node_modules/path-is-absolute
       graceful-fs@4.2.2 /tmp/build_514cee29_/node_modules/graceful-fs
       handlebars@4.7.6 /tmp/build_514cee29_/node_modules/handlebars
       minimist@1.2.5 /tmp/build_514cee29_/node_modules/minimist
       neo-async@2.6.2 /tmp/build_514cee29_/node_modules/neo-async
       source-map@0.6.1 /tmp/build_514cee29_/node_modules/source-map
       wordwrap@1.0.0 /tmp/build_514cee29_/node_modules/wordwrap
       object.assign@4.1.0 /tmp/build_514cee29_/node_modules/object.assign
       define-properties@1.1.3 /tmp/build_514cee29_/node_modules/define-properties
       object-keys@1.1.1 /tmp/build_514cee29_/node_modules/object-keys
       function-bind@1.1.1 /tmp/build_514cee29_/node_modules/function-bind
       has-symbols@1.0.0 /tmp/build_514cee29_/node_modules/has-symbols
       promise@8.0.3 /tmp/build_514cee29_/node_modules/promise
       asap@2.0.6 /tmp/build_514cee29_/node_modules/asap
       accepts@1.3.7 /tmp/build_514cee29_/node_modules/accepts
       mime-types@2.1.27 /tmp/build_514cee29_/node_modules/mime-types
       mime-db@1.44.0 /tmp/build_514cee29_/node_modules/mime-db
       negotiator@0.6.2 /tmp/build_514cee29_/node_modules/negotiator
       array-flatten@1.1.1 /tmp/build_514cee29_/node_modules/array-flatten
       body-parser@1.19.0 /tmp/build_514cee29_/node_modules/body-parser
       bytes@3.1.0 /tmp/build_514cee29_/node_modules/bytes
       content-type@1.0.4 /tmp/build_514cee29_/node_modules/content-type
       debug@2.6.9 /tmp/build_514cee29_/node_modules/debug
       ms@2.0.0 /tmp/build_514cee29_/node_modules/ms
       depd@1.1.2 /tmp/build_514cee29_/node_modules/depd
       http-errors@1.7.2 /tmp/build_514cee29_/node_modules/http-errors
       inherits@2.0.3 /tmp/build_514cee29_/node_modules/http-errors/node_modules/inherits
       setprototypeof@1.1.1 /tmp/build_514cee29_/node_modules/setprototypeof
       statuses@1.5.0 /tmp/build_514cee29_/node_modules/statuses
       toidentifier@1.0.0 /tmp/build_514cee29_/node_modules/toidentifier
       iconv-lite@0.4.24 /tmp/build_514cee29_/node_modules/iconv-lite
       safer-buffer@2.1.2 /tmp/build_514cee29_/node_modules/safer-buffer
       on-finished@2.3.0 /tmp/build_514cee29_/node_modules/on-finished
       ee-first@1.1.1 /tmp/build_514cee29_/node_modules/ee-first
       qs@6.7.0 /tmp/build_514cee29_/node_modules/qs
       raw-body@2.4.0 /tmp/build_514cee29_/node_modules/raw-body
       unpipe@1.0.0 /tmp/build_514cee29_/node_modules/unpipe
       type-is@1.6.18 /tmp/build_514cee29_/node_modules/type-is
       media-typer@0.3.0 /tmp/build_514cee29_/node_modules/media-typer
       content-disposition@0.5.3 /tmp/build_514cee29_/node_modules/content-disposition
       safe-buffer@5.1.2 /tmp/build_514cee29_/node_modules/safe-buffer
       cookie@0.4.0 /tmp/build_514cee29_/node_modules/cookie
       cookie-signature@1.0.6 /tmp/build_514cee29_/node_modules/cookie-signature
       destroy@1.0.4 /tmp/build_514cee29_/node_modules/destroy
       encodeurl@1.0.2 /tmp/build_514cee29_/node_modules/encodeurl
       escape-html@1.0.3 /tmp/build_514cee29_/node_modules/escape-html
       etag@1.8.1 /tmp/build_514cee29_/node_modules/etag
       express@4.17.1 /tmp/build_514cee29_/node_modules/express
       finalhandler@1.1.2 /tmp/build_514cee29_/node_modules/finalhandler
       parseurl@1.3.3 /tmp/build_514cee29_/node_modules/parseurl
       fresh@0.5.2 /tmp/build_514cee29_/node_modules/fresh
       merge-descriptors@1.0.1 /tmp/build_514cee29_/node_modules/merge-descriptors
       methods@1.1.2 /tmp/build_514cee29_/node_modules/methods
       path-to-regexp@0.1.7 /tmp/build_514cee29_/node_modules/path-to-regexp
       proxy-addr@2.0.6 /tmp/build_514cee29_/node_modules/proxy-addr
       forwarded@0.1.2 /tmp/build_514cee29_/node_modules/forwarded
       ipaddr.js@1.9.1 /tmp/build_514cee29_/node_modules/ipaddr.js
       range-parser@1.2.1 /tmp/build_514cee29_/node_modules/range-parser
       send@0.17.1 /tmp/build_514cee29_/node_modules/send
       mime@1.6.0 /tmp/build_514cee29_/node_modules/mime
       ms@2.1.1 /tmp/build_514cee29_/node_modules/send/node_modules/ms
       serve-static@1.14.1 /tmp/build_514cee29_/node_modules/serve-static
       utils-merge@1.0.1 /tmp/build_514cee29_/node_modules/utils-merge
       vary@1.1.2 /tmp/build_514cee29_/node_modules/vary
       uglify-js@3.11.1 /tmp/build_514cee29_/node_modules/uglify-js
       Installing any new modules (package.json)
       removed 50 packages and audited 26 packages in 0.974s
       found 0 vulnerabilities
       
       
-----> Build
       
-----> Caching build
       - node_modules
       
-----> Pruning devDependencies
       audited 26 packages in 0.444s
       found 0 vulnerabilities
       
       
-----> Build succeeded!
 !     This app may not specify any way to start a node process
       https://devcenter.heroku.com/articles/nodejs-support#default-web-process-type
-----> Discovering process types
       Procfile declares types     -> (none)
       Default types for buildpack -> web
-----> Compressing...
       Done: 25.8M
-----> Launching...
       Released v11
       https://kbrus87-mp-commerce-nodejs.herokuapp.com/ deployed to Heroku

但是当我转到链接时,它显示应用程序错误。

我的package.json是

    {
  "name": "mp-ecommerce-nodejs",
  "version": "1.0.0",
  "description": "",
  "main": "app.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "express-handlebars": "^3.1.0"
  }
}

知道发生了什么吗?

1 个答案:

答案 0 :(得分:0)

您的package.json没有任何npm start脚本,Heroku需要此脚本来运行您的应用。因此,如果您有一个.js文件,例如app.js,您必须将其添加到package.json中,如下所示:

{
  "name": "mp-ecommerce-nodejs",
  "version": "1.0.0",
  "description": "",
  "main": "app.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node app.js"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "express-handlebars": "^3.1.0"
  }
}