Ng serve for angular application is not starting the server - node.js

We are using node server to start our angular application using npm run. Due to strange reasons application is taking lot of time to render on browser whenever there is a change and angular build runs.
If there are no changes/ no angular build is run, if we reload the page it loads fast.
We are suspecting the issue is with node and want to run the angular application standalone using ng serve. But running this command is just building but not starting the server.
Need guidance on how we can keep node and run the angular application fast on browser. If not, please suggest where to look if I had to fix ng serve command to start the angular server as standalone

Related

Run Node.js server and yarn serve vue-cli app at the same time

I've only start learning vuejs recently and I'm trying to build a real-time messaging apps. I was following this tutorial and able to get the nodejs server running but it would require me to use the command "node myapp.js" every single time and I can't run my vuejs apps after running nodejs server unless i stopped it with ctrl+c and type "yarn serve" again. How do I run the apps and trigger the server at the same time? I would really appreciate suggestions, thanks :)
You could try either of these packages:
npm-run-all
concurrently
Or just open up two console windows 😆
Try something like Node Foreman

How to debug Angular universal?

I am using Angular Universal Starter repo. In angular 4 universal for ssr we could debug browser and node part of application in dev mode(see console), but now I do not see way to debug node part. I tried to execute ts-node server.ts with some changes( paths to files, etc), but angular seems needs aot compiled app and
throw Error: You must pass in a NgModule or NgModuleFactory to be
bootstrapped.
from docs:
Development (Client-side only rendering)
- run npm run start which will start ng serve
Production (also for testing SSR/Pre-rendering locally)
- npm run build:ssr && npm run serve:ssr
At first glance debug on Node.js in development do not work. At least from the box. May be someone resolve this issue.
You can't debug node part of your Angular 4 app in browser. Node work on server part so you can't see this in browser (client side).
Only way to debug this part when you start it from ts-node server.ts is to use external tools like WebStorm etc. If you start your App in TS mode from Debug mode you can use all features of this tools.
I think this small piece of code can help you
create the project
ng n debuggable-universal-server --interactive=false
cd debuggable-universal-server
add universal
ng add #nguniversal/express-engine --clientProject debuggable-universal-server
To create the server-side app module, app.server.module.ts, run the following CLI command.
ng add #nguniversal/express-engine
To start rendering your app with Universal on your local system, use the following command.
npm run dev:ssr

How to run and work with Node.js on my remote VPS

Maybe it is dummy or noob question, but this is the first time I am trying to run / deploy my local Node.js application to the internet via my VPS hosting.
When working locally, I am using nodemon package to auto restart the server on each change.
Also, when turn off the terminal or shut down the Mac, the Node.js will be shut down too.
How these things could be handled via a remote VPS with a public domain?
Btw, another thing is how to compress/compile/hide/secure my client side code so it wont be able to be read or something.
I am asking this because when I am doing source code, It is very clear to see the whole app requests and therefore "play" with this.
Thanks.
check out pm2 (production node manager)
you can install like this
npm install pm2 -g
so instead of nodemon app.js you'll run
pm2 start app.js
instead. This keeps your app running even if you restart your server
check out the official site for more info on pm2

Create-react-app npm run build too slow

I am relatively new to using React and am following create-react-app tutorials. I am creating a simple webchat service using socket.io, React, and Express in a Node environment.
I've finished writing the majority of the features for the React app and am now working on the server end to connect the apps via Socket.io. Working on the front-end was each because I could just run "npm start" to serve a dev version of my app. However, now that I am working on the server side, implementing Socket.io, whenever I find an issue on the front-end, I have to rerun "npm run build" which takes ~15-30 seconds each time.
I am sure there is a faster way to debug issues like this without having to compile my react app into static files every time. Please advise.
You should run the front end using npm command on cmd panel npm start and debug the backend server side using VSCode Debugger using the node js extension. This way you can run both on dev easily. Plus it give you advance debugging features.

ruining EasyRTC server using iisnode

EasyRTC is one of the best available opensource WebRTC solutions that runs in node.js! I have manged to run it on node.js on my system but my application is in Asp.net so I've been trying to run it using under IIS using iisnode! but for some reason I haven't been able to make it work! running this application in node.js i use node server.js to start the server but in IIS when i set the default page to server.js to start the application it wond work!
this is result by using
nodejs:
nodejs result: (working properly)
IISNODE Result:
looks like it's not even running it !
This error is due to lack required module for easyRTC. type in node command prompt "npm install" It will install all dependency module. And after that try to run server. I hope It will work for you.

Resources