簡體   English   中英

Heroku應用程序錯誤,但已經成功構建

[英]Heroku Application Error but already building successfully

Heroku日志在這里,我從此日志中看不到任何錯誤:

-----> Node.js app detected
-----> Creating runtime environment

       NPM_CONFIG_LOGLEVEL=error
       NPM_CONFIG_PRODUCTION=true
       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 6.x...
       Downloading and installing node 6.11.2...
       Using default npm version: 3.10.10
-----> Restoring cache
       Loading 2 from cacheDirectories (default):
       - node_modules
       - bower_components (not cached - skipping)
-----> Building dependencies
       Installing node modules (package.json)
-----> Caching build
       Clearing previous node cache
       Saving 2 cacheDirectories (default):
       - node_modules
       - bower_components (nothing to cache)
-----> Build succeeded!
-----> Discovering process types
       Procfile declares types -> web
-----> Compressing...
       Done: 19.1M
-----> Launching...
       Released v49
       xxxx deployed to Heroku

一切似乎都很好,但是打開應用程序時出現應用程序錯誤。 我的應用程式怎么了?

以下是包裝:

    "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node server.js"
    },
    "repository": {
    "type": "git",
    "url": "xxx.git"
    },

這是用於設置端口和偵聽端口的服務器文件,我將端口設置為3000:

app.set('port', (process.env.PORT || 3000));
app.use(express.static(__dirname+'/public/assignment'));

app.listen(app.get('port'), function() {
    console.log('Node app is running on port', app.get('port'));
});

嘗試將靜態路徑扭曲到path模塊中

const path = require('path');
app.use(express.static(path.join(`${__dirname}/public/assignment`)));

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM