How do I deploy an Angular 2 app on Bluemix?

丶灬走出姿态 提交于 2019-12-01 07:24:31

问题


I have tried to deploy a few basic Angular 2 projects on Bluemix and got only errors after the build.

Did anybody manage to have Angular 2 working on Bluemix? In that case, did you set anything specific in package.json file?

I couldn't get over this error message:

npm ERR! code ELIFECYCLE
npm ERR! argv "/home/vcap/app/vendor/node/bin/node" "/home/vcap/app/vendor/node/bin/npm" "run" "tsc:w"

回答1:


It would be great to post a sample or a link to your source code. But from the two log lines it sounds like you are trying to deploy the Angular 2 app including the Node.js tooling it comes with.

As pointed by the previous comment, you'd rather build your Angular 2 app and deploy the resulting files, keeping the Node.js tooling for your local development.

I've put together a sample doing just that https://github.com/l2fprod/bluemix-hello-angular2. Consider it an even simpler version of the above example.

It is a new project generated with the angular-cli, then I did the minimum required changes to deploy the build to Bluemix.




回答2:


There are a few ways to deploy an angular2 app to Bluemix.

  1. You can export your static files and push the dist folder along with manifest.yml file https://docs.cloudfoundry.org/buildpacks/staticfile/index.html

  2. You can deploy your app in a Docker container with your nginx.conf file

I highly recommend deploying the app in a Docker container. It will give you more freedom in development.

Here is a post I find really useful. http://heidloff.net/article/angular-2-bluemix-docker-nginx

I hope this can help




回答3:


I created a sample app using Frederic Lavigne's sample project and deployed it to bluemix. https://github.com/joeydeluca/petstore-client-angular2




回答4:


There is a new angular2-on-bluemix example created from the official AngularJs 2 tutorial (Tour of Heroes): https://github.com/nnworkspace/angular2-heroes-bluemix



来源:https://stackoverflow.com/questions/39594760/how-do-i-deploy-an-angular-2-app-on-bluemix

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!