2017-08-08 89 views
0

Heroku的日誌在這裏,我看不到任何錯誤了該日誌:的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')); 
}); 

回答

0

嘗試翹曲靜態路徑進入path模塊

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