的Heroku应用程序错误,但已成功构建
问题描述:
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'));
});
答
尝试翘曲静态路径进入path
模块
const path = require('path');
app.use(express.static(path.join(`${__dirname}/public/assignment`)));