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 :(得分:0)
尝试将静态路径变形为path
模块
const path = require('path');
app.use(express.static(path.join(`${__dirname}/public/assignment`)));