0

I am done with my development on angular2 and now want to deploy this in production. My backend is a springboot app so i can deploy it directly.

But I want to know how can I deploy angular2 in production? Do I need to install Node.js or it can be deployed independently of it?

Also, can I deploy it as a part of springboot app itself?

5
  • Building the app should produce a dist folder, then you just serve that folder on the backend of your choice. Commented Aug 1, 2017 at 3:58
  • Dist folder doesn't have anything. Do I need to add anything in package.json to create files in dist or run any command for it? Commented Aug 1, 2017 at 4:14
  • 2
    You should run ng build and this should create a dist folder Commented Aug 1, 2017 at 5:04
  • ng build giving me below error:- 'Error: The "@angular/compiler-cli" package was not properly installed. Error: TypeError: Object prototype may only be an Object or null: undefined'. i even tried to install again by deleting node_module but still same error. Commented Aug 1, 2017 at 6:42
  • That's too vague of an error to diagnose here. I'd recommend asking another question with that specific error, or I'm sure there are already questions asked addressing that issue. Commented Aug 1, 2017 at 6:53

2 Answers 2

1

ng build will produce dist folder where it contains all required files you can use that file any where to run your angular project.

Sign up to request clarification or add additional context in comments.

Comments

1

You can use:

  1. nginx
  2. spring boot to serve static content
  3. Azure/AWS web app
  4. or any other platform to host static contents

just be aware of security features which a web server provides like CORS, x-frame options to name a few

4 Comments

Security is fine as it will be used only on intranet. I dont want to use any server for angular2. Is there anyway to extract the js files and put them in springboot and just run the springboot jar.
spring.io/blog/2013/12/19/… Yes, just copy the build artifacts of your angular2 project to resources of spring boot and done!!
Do I need to copy node_modules as well? or just my js files built from .ts files?
just the built folder assuming you have built using browserify/webpack which includes the required node packages in the main ts files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.