How to deploy Angular universal - node.js

I looking into Angular universal and trying to get my head around deployment.
Github https://github.com/angular/universal-starter
It has Angular 2 Universal + TypeScript 2 + Webpack 2
When I run the command
npm run build
I get the following structure
**Client**
0.bundle
0.bundle.js.map
main.bundle
main.bundle.js.map
**Server**
0.index
0.index.js.map
index
index.js.map
How do I deploy this to a server?

Install dependencies
Run npm install in your terminal at the root of universal-starter
Run the NodeJS backend
Run npm run build:ssr && npm run serve:ssr after npm install has finished, this will host a local nodejs server here: http://localhost:4000 (you can put that in your browser)
Before either of these steps ensure you have NodeJS and NPM installed (NPM comes with the newer builds of NodeJS)

Related

Why does my Next.JS edit code work (on npm run start)? without new build (on npm run build)

Why does my Next.JS edit code work (on npm run start)? without new build (on npm run build). I wonder why it is so. Or did I do something wrong?
In nextjs .. if you want to run development server, you have to run
npm run dev
npm run start --> Runs your production build.
Please check your scripts in package.json

Define custom npm install procedure for azure/webapps-deploy#v2

My project currently contains 2 apps. The first is the application Backend (NestJS) and the second is the client (VueJS).
The current folder structure follows:
Root (NestJS)
./client/ (VueJS)
When I am deploying my app to Azure App Service I am using the azure/webapps-deploy#v2 action. It's procedure is to run npm install in the root of the project but I need it to also run in the sub project containing the client packages. How can this be done? Are there any arguments to provide the webapps deploy action to include that addition npm install command?
You could try add the commands directly in your workflow:
- name: npm install, build, and test
run: |
npm install
npm run build --if-present
npm run test --if-present
cd ./client/mern_azure_example # go to your client package
npm install # run npm install under your client package
But it takes very long time.

can we deploy an react js application without source(src folder) code locally

some background:this is my first react application and my assumption is build in react is similar to binary files in c++
question : this is for a react application which sole purpose is to run locally. is there anyway we can do npm start only with build
have tried to delete the src folder after building.
expected result is the app should run as usual.
actual result : app crashes saying, index.js file is missing
npm start won`t work with build version,
you need to install serve and run build using serve locally on your machine
npm install -g serve
serve -s build
ref: https://facebook.github.io/create-react-app/docs/deployment

Build Vue.js in production serve

I want to build the default template of Vue.js
vue init webpack
with this command
node build/build.js
Instead of having the same page that I have when running npm run dev I have a blank page.
Also I run npm run build
How to convert this site into a non-develop website ?
Vue version 2.9.6
Node version v8.15.1

'npm EER! code 1' When installing dependencies using `npm install --production`

I am using flightplan to deploy my node.js application to my server. I run the command fly production in my CLI to deploy my app to the server. It does rsync fine, but when it comes to installing dependencies, I get the following error:
I made sure that I have sudo privileges on my server for this user and npm is definitely installed as it gives the version number when I run the command npm -von my server. I have tried to run npm install --production myself on the server as the deploy script does and I get the same error, meaning it is something to do with installing dependencies. Potentially, it could be because in my flightplan.js, when it runs the command git ls-files to get the files to copy across. it includes all the node_modules even though i've made sure that node_modules is in the .gitingore file.
Does anyone have experience with flightplan npm module/or know why my npm install isn't working on my server?
(I edited out my server IP address from the picture)
Thanks in advance!
I found that if I removed the node_modules folder by running command rm -rf node_modules/ then committed this to github, then re-ran npm install and then my call to fly production worked successfully.

Resources