我需要问有关角度相关问题的问题

时间:2019-04-03 07:11:51

标签: angular heroku

我已将我的角度应用程序上传到Heroku云平台并成功部署,但是当我打开该应用程序时出现一些错误 “未找到”

有人可以给我解决这个问题的方法吗?

我还为此应用添加了构建包作为Node。



remote: -----> Build
remote:        Running build
remote:
remote:        > reis@0.0.0 build /tmp/build_2e7d87e0fbcf9c8257f0de6348da3080
remote:        > ng build
remote:
remote:
remote:        Date: 2019-04-03T06:02:47.407Z
remote:        Hash: 64eb65cb04648b6fba2c
remote:        Time: 11016ms
remote:        chunk {main} main.js, main.js.map (main) 42.2 kB [initial] [rendered]
remote:        chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 236 kB [initial] [rendered]
remote:        chunk {runtime} runtime.js, runtime.js.map (runtime) 6.08 kB [entry] [rendered]
remote:        chunk {scripts} scripts.js, scripts.js.map (scripts) 84.9 kB  [rendered]
remote:        chunk {styles} styles.js, styles.js.map (styles) 16.8 kB [initial] [rendered]
remote:        chunk {vendor} vendor.js, vendor.js.map (vendor) 3.35 MB [initial] [rendered]
remote:
remote: -----> Caching build
remote:        - node_modules
remote:
remote: -----> Pruning devDependencies
remote:        removed 682 packages and audited 17509 packages in 11.701s
remote:        found 1 low severity vulnerability
remote:          run `npm audit fix` to fix them, or `npm audit` for details
remote:
remote: -----> Build succeeded!
remote:
remote: -----> Change to Node.js build process
remote:        Heroku has begun executing the "build" script defined in package.json
remote:        during Node.js builds.
remote:
remote:        Read more: https://devcenter.heroku.com/changelog-items/1573
remote:
remote: -----> Discovering process types
remote:        Procfile declares types     -> (none)
remote:        Default types for buildpack -> web
remote:
remote: -----> Compressing...
remote:        Done: 56.2M
remote: -----> Launching...
remote:        Released v4
remote:        https://reis-bahria.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/reis-bahria.git
   f0f843b..577c801  master -> master

1 个答案:

答案 0 :(得分:-1)

我认为server.js文件中可能存在问题。如果角度版本为6或更高,则提供的路径必须包含项目名称。

app.use(express.static(__dirname + '/dist/<project-name>'));

app.get('/*', function(req,res) {

res.sendFile(path.join(__dirname+'/dist/<project-name>/index.html'));
});