我从Git在Heroku上部署了Angular 5项目,但在Heroku上获得了“未找到”页面。
我按照这篇文章在Heroku上进行了设置: https://medium.com/@hellotunmbi/how-to-deploy-angular-application-to-heroku-1d56e09c5147
这是关于Git的Angular 5项目: https://github.com/dilkash133/On-Demand-Eye
以下是Heroku构建日志:
-----> Node.js app detected
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NODE_VERBOSE=false
NODE_ENV=production
NODE_MODULES_CACHE=true
-----> Installing binaries
engines.node (package.json): 8.11.3
engines.npm (package.json): 5.6.0
Resolving node version 8.11.3...
Downloading and installing node 8.11.3...
npm 5.6.0 already installed with node
-----> Restoring cache
Loading 2 from cacheDirectories (default):
- node_modules
- bower_components (not cached - skipping)
-----> Building dependencies
Installing node modules (package.json + package-lock)
> on-demand-eye@0.0.0 postinstall /tmp/build_8f0e6a78870c4adbe6e129584a635355
> ng build --aot=prod
31% building modules 175/1 Date: 2018-06-24T16:37:06.093Z
Hash: c1e413ba83cf3ae7164c
Time: 11736ms
chunk {main} main.js, main.js.map (main) 62.5 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 227 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 5.22 kB [entry] [rendered]
chunk {scripts} scripts.js, scripts.js.map (scripts) 158 kB [rendered]
chunk {styles} styles.js, styles.js.map (styles) 167 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 2.96 MB [initial] [rendered]
up to date in 24.049s
-----> Caching build
Clearing previous node cache
Saving 2 cacheDirectories (default):
- node_modules
- bower_components (nothing to cache)
-----> Pruning devDependencies
Skipping because npm 5.6.0 sometimes fails when running 'npm prune' due to a known issue
https://github.com/npm/npm/issues/19356
You can silence this warning by updating to at least npm 5.7.1 in your package.json
https://devcenter.heroku.com/articles/nodejs-support#specifying-an-npm-version
-----> Build succeeded!
-----> Discovering process types
Procfile declares types -> (none)
Default types for buildpack -> web
-----> Compressing...
Done: 72.7M
-----> Launching...
Released v5
https://on-demand-eye.herokuapp.com/ deployed to Heroku
server.js
//Install express server
const express = require('express');
const path = require('path');
const app = express();
// Serve only the static files form the dist directory
app.use(express.static(__dirname + '/dist'));
app.get('/*', function(req,res) {
res.sendFile(path.join(__dirname+'/dist/index.html'));
});
// Start the app by listening on the default Heroku port
app.listen(process.env.PORT || 8080);