将 Angular 6 部署到赫鲁科错误



我刚刚将一个工作的Angular 6应用程序部署到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.2
engines.npm (package.json):   6.0.1
Resolving node version 8.11.2...
Downloading and installing node 8.11.2...
Bootstrapping npm 6.0.1 (replacing 5.6.0)...
npm 6.0.1 installed
-----> Restoring cache
Skipping cache restore (not-found)
-----> Building dependencies
Installing node modules (package.json + package-lock)
> uws@9.14.0 install /tmp/build_783e57ef498fd0603b4e43ee31371597/node_modules/uws
> node-gyp rebuild > build_log.txt 2>&1 || exit 0

> node-sass@4.9.0 install /tmp/build_783e57ef498fd0603b4e43ee31371597/node_modules/node-sass
> node scripts/install.js
Downloading binary from https://github.com/sass/node-sass/releases/download/v4.9.0/linux-x64-57_binding.node
Download complete
Binary saved to /tmp/build_783e57ef498fd0603b4e43ee31371597/node_modules/node-sass/vendor/linux-x64-57/binding.node
Caching binary to /tmp/npmcache.TL2N2/node-sass/4.9.0/linux-x64-57_binding.node
> node-sass@4.9.0 postinstall /tmp/build_783e57ef498fd0603b4e43ee31371597/node_modules/node-sass
> node scripts/build.js
Binary found at /tmp/build_783e57ef498fd0603b4e43ee31371597/node_modules/node-sass/vendor/linux-x64-57/binding.node
Testing binary
Binary is fine
> @angular/cli@6.0.8 postinstall /tmp/build_783e57ef498fd0603b4e43ee31371597/node_modules/@angular/cli
> node ./bin/ng-update-message.js

> schoolsdropdown@0.0.0 postinstall /tmp/build_783e57ef498fd0603b4e43ee31371597
> ng build --aot -prod
Unknown option: '-p'
added 1196 packages from 1369 contributors in 46.334s
[!] 6 vulnerabilities found [22390 packages audited]
Severity: 1 Low | 5 Moderate
Run `npm audit` for more detail
-----> Caching build
Clearing previous node cache
Saving 2 cacheDirectories (default):
- node_modules
- bower_components (nothing to cache)
-----> Pruning devDependencies
removed 844 packages in 12.953s
[+] no known vulnerabilities found [9170 packages audited]
-----> Build succeeded!
-----> Discovering process types
Procfile declares types     -> (none)
Default types for buildpack -> web
-----> Compressing...
Done: 46.5M
-----> Launching...
Released v3
https://schoolsdropdown.herokuapp.com/ deployed to Heroku

-prod 选项有问题吗? 如何解决这个问题?

任何帮助将不胜感激。提前谢谢。

我认为你做错了事。你想要的是使用 Angular CLI 生成生产构建 (https://github.com/angular/angular-cli/wiki/build;ng build(,并将此生产构建/输出目录上传到 Heroku(有关详细信息,请参阅 http://blog.teamtreehouse.com/deploy-static-site-heroku(。

否则:您必须添加--prod而不是-prod

总结一下聊天:问题是服务器.js文件在src目录中,而不是在基目录中,而是在package.json中指定的基目录。

最新更新