将Angular 6部署到Heruko错误

时间:2018-06-12 05:16:55

标签: angular heroku

我刚刚向Heroku部署了一个正在运行的Angular 6应用程序。它成功构建,但页面不会显示。页面上写着,

  

应用程序中发生错误,您的页面无法执行   提供服务。如果您是应用程序所有者,请检查日志以获取详细信息

以下是日志:

 -----> 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选项有问题吗?如何解决这个问题?

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

1 个答案:

答案 0 :(得分:2)

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

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

总结聊天:问题是server.js文件位于src目录而不是基本目录中,但是package.json是指定的基目录。