How to deploy Angular Universal project to standard hosting?

12,077

So I have deployed my Angular Universal project to my hosting.

I can say that the support team of my hosting gave me a lot of help. I don't know if is it possible to deploy such project on the own.

My hosting has a Node.js support. Support team of the hosting gave me an instruction how to install Node.js on the hosting using terminal on Mac or programs for Windows like PuTTY.

Then I walked through the following steps:

  1. Create the folder for the project on the hosting.
  2. Copy the dist folder to created folder.
  3. Install NPM in the project folder. At this step support team gave me some help. Because you should do something with PATH to proper install and work of NPM.
  4. Standard hosting links the public_html folder to your domain name. But Angular Universal project should be in a separate folder. So I have asked the support to redirect my domain to the Angular project folder and proper port.
  5. Run server using terminal:

node dist/server/server.js

After all I can see my project working good on my domain name.

Addition. Also I tried the following way: copied my project folder (without node_modules folder) to the hosting and then run

npm install

npm run build

You can create the dist folder on the hosting also by these commands.

Addition. Assume that you config your Node.js server on your hosting. Also you should make shure that your project ready to be deployed. Here is a link what code needs to prepair this: https://github.com/angular/angular-cli/wiki/stories-universal-rendering

You also need to copy on your hosting your client/ and server/ folders and also server.js and package.json files. Then you can run your application by

node server.js

Share:
12,077
Kirill Ch
Author by

Kirill Ch

I graduated Lomonosov Moscow State University in 2002, faculty of Computational Mathematics and Cybernetics. Operations Research department. Then had 2 years of post-graduate study. Worked as Visual Basic developer, analyst in Moscow Domodedovo airport, business development manager. In 2014 I came to Web-development (js, Angular, d3.js, Highcharts.js) and then went to Java-development that I like the most. Now I'm working as a Backend Java-developer. My stack of technologies: Java SE 8, Spring Boot, Hibernate, JPA, Spring Security have some experience with Python, NetworkX, Neo4j For the last several years I have worked with a number of sources: web-services SOAP/REST (LexisNexis, Prima-Inform, Dofin, PravoRu), also Splunk system of large bank. I have been creating server components and REST API to integrate these data sources with visual data analysis systems. Use Oracle, PostgreSQL, MySQL, sometimes H2. Work with FTP-servers, process data from sites, work with various formats of data like XML, JSON, XSD, WSDL, Excel, CSV, ZIP, etc. Have built backend solutions for such large Russian companies like SIBUR, Sber Capital, Central bank of Russia.

Updated on June 13, 2022

Comments

  • Kirill Ch
    Kirill Ch almost 2 years

    I have my Angular Universal project working on my localhost. So now I would like to test it on my standard web hosting with Node.js installed.

    I have run:

    npm run build 
    

    and received dist folder with client and server subfolders.

    How should I use these folders and files into them to run the project on the hosting?

    Thanks.

  • Chris Sainty
    Chris Sainty almost 7 years
    What hosting provider do you use?
  • Kirill Ch
    Kirill Ch almost 7 years
    I used Beget.com. The project was deployed, however there was a problem with working with data. On my local machine the project worked perfectly but after deployment I could see the front-client but no data was loading, I tried something but couldn't solve the issue. As it was my testing efforts I didn't go futher.
  • chozha rajan
    chozha rajan about 6 years
    @Kirill Ch can u share your website Url link here and if you now know all that steps means explain again or any reference url
  • Kirill Ch
    Kirill Ch about 6 years
    @chozharajan Sorry, I now don't use Angular Universal any more as I create only corporate systems where Universal and its page rendering is unnecessary.
  • RaJesh RiJo
    RaJesh RiJo almost 6 years
    @KirilCh I am getting client and server folder in dist folder. How to proceed further procedure. Please tell step by steps
  • kamalav
    kamalav almost 6 years
    @KirilCh pls provide more information.Me also struggling on this
  • Kirill Ch
    Kirill Ch almost 6 years
    @kamalav Good day. I haven't use Universal for a long time now. When I deployed my project - the support team gave my a lot of help, some features they config by themselves as I told in the answer. Other steps I think are clearly described in the answer, they are not very difficult. Also see my addition about preparation the project to proper deploy.
  • EddyG
    EddyG almost 5 years
    @KirillCh where do you host your website? and how much you pay per month? It is not a shared server right? Because I host on bluehost on a shared server, and they told me that it does not support NodeJs. So in other words, I am not able to deploy my "universal build" on it!!
  • Kirill Ch
    Kirill Ch almost 5 years
    @EddyG ye, I see. I used standard hosting and provider with Node.js support. It seems major providers give such option and technical help if nesessary. At any case you can get an instruction how to use your Node.js at them. My provider is Russian (as I am) - Beget.com. I use simple standard service package it is about 5$ per month.
  • EddyG
    EddyG almost 5 years
    @KirillCh Thanks for sharing. I host on bluehost which is popular, but doesn't support Node.js on standard hosting plans!! But, I found a solution that makes a static rendering without requiring Node.js, by posting a question here, check it: stackoverflow.com/questions/56515353/…