Docker vs node.js - node.js

I'm fairly new to React-native. Im sorry about quite a convoluted question but I have dilemma. I am building an API that communicates with a server app that Im working on, I have been using Docker successfully to run containers BUT I'm constantly being told that I don't need to run Docker at all. I understand the principles of Docker and Node.JS but in all honesty I cant imagine how I would run server side without Docker. Ive tried Node.js and seemed to require a PHP server, which I was also told I did not need. Is this true? which is better Docker or Node.JS? and If Node JS is better how to run it without a php server as it is my understanding that php serves the pages and React consumes the pages.

'You can just install Node, frequently through your OS's package manager. It doesn't require PHP or other language interpreters. I find working directly with Node much easier than using Node in Docker: it is actually a local development environment that my IDE is comfortable with, and not a path to run a Node interpreter "somewhere else" that's isolated from my desktop tooling. '
1)After a few weeks of research I found that I didn't need docker at all. Within Node is the ability to run a server using either fastify or express. I just needed to check on the relevant documentation for usage
2) I linked fastify to ngrok and exposed my local IP address to a public facing direction
3) I linked the ngrock url to my freedns and voila! it worked!
4) I had a small problem with the port which was resolved by using
the command ngrok http 127.0.0.1:5000

Related

How to hot reload on netlify?

Netlify just as example, same question with CloudFlare Pages etc.
In the past I setup my own server with node and react/vue.
I have my node setup on a server because I don't want to install node and node packages on my local machine.
When I was developing I SSH into the server with port forwarding.
So I ran a dev server on port 8888 (npm run dev) on the server and opened http://localhost:8888 in my local browser.
When I make a change to the files I can immediately see the effects without running npm run build.
I am thinking about using a service like netlify because its the right thing to do? But how can I see the changes I make without actually running build?
Is this even possible or do you use theses service only when you are building a website that rarely changes? I am probably missing something. But not sure how to proceed.
I don't know what's the right way. I am very open to suggestions.
Edit: These services that I mentioned are meant for build only. See answer below. I am still leaving this question so people can post suggestions.
You cannot do this. Those services are only for hosting the build version of your app. You have to develop it locally and push the build to these services.
Why would you even want to run a development version online?

How to 'build' a node js application?

I have a node.js application that run as a application server.
It is deployed on an Ubuntu 20.04 machine running on AWS, uses nginx as a reverse proxy and PM2 as a service starter.
Everything seems perfectly configured.
What looks strange to me, is that I have a React application, in a similar environment, but, before to move it on the server, I run build it, so creating a sort of packed and not easily human readable application.
My question is: Is there the need to do the same with a node.js application?
And, in case of positive answer, How to 'build' a node.js application?
There is no need to build a normal nodejs application.
What you mean is the use of a bundler e.g. webpack and a javascript compiler e.g. babel. To create a react application, you usually use a tool like create-react-app that sets up all this stuff for you. For react you need the compilation beacause you use the jsx syntax that browsers do not understand. In addition to that a bundler has some more advantages.
Check out this video if you want to know more about it:
https://www.youtube.com/watch?v=5IG4UmULyoA
No you don't have to build anything for node.js you just have to run the server. for client side apps you need to build and serve the Dist through web servers like apache or nginx.

How to deploy React.js with Node backend in IIS?

I have an application built with Create React App that I want to use Node.js as a backend to load data from a database. Basically, I want Node to load the data and then use Create React App to do stuff with it. To do so I used this tutorial: https://www.freecodecamp.org/news/how-to-make-create-react-app-work-with-a-node-backend-api-7c5c48acb1b0/. I have set up a working development environment where I have all the Create React App in a client folder, a server.js that loads the data (from MS SQL Server if that's relevant), and a proxy set in client/package.json (CRA's package.json) for the port that the node app is running on (5000 in my case). I then run yarn dev and these two servers run together and talk to each other and everything works great.
The issue is deploying. My organization uses IIS. From what I can gather Node and IIS are not the ideal combination but IIS is what we use for everything. I would like the server.js and the CRA to be in the same folder and to basically function like one app as much as possible (I know that Node will need to run its own server). I would also like a setup that can be easily changed or moved to another machine. What I've done thus far is:
Set up a single application with a client folder, which is the build for CRA, and then server.js in the root
In my react code, made API calls to http://localhost:5000 (in the development environment I could do fetch('api/somestuff') but to make it work in production I needed to do fetch('http://localhost:5000/api/somestuff') )
Installed pm2 and used it to run server.js and start the Node server
This worked, however I'm wondering whether this is the optimal way to do things. This worked on my local machine but I don't know what will happen when I put it on our production machines. Will the Node server block other applications? Will it stay running no matter what or might it crash? Ultimately this is going to be deployed in a multi-server environment where we have 2 load-balanced servers with identical code that are put through an F5 to form a single URL--will this impact anything?
I'm pretty new to programming so bear with me, I'm sorry if this question was confusingly phrased.
I suggest you install ARR to work with IIS as a reverse proxy, which can forward the HTTP request to the backend NodeJS server.
Besides, for cross-domain request forwarding in the rewrite action type, we need to install Application Request Routing, and enable the proxy functionality.
Here are two examples of applying this feature, please check it.
How to successfully run node server with IIS?
ASP.net URL Rewrite subdirectory to external URL
Feel free to let me know if there is anything I can help with.

Run React basic app on ubuntu using node js

I am fairly new to NodeJS, here is the problem statement:
I have a small app (let's consider default app) of ReactJS. I installed NodeJs on my Ubuntu Server. Now when I hit mydomain.com in a browser I want my ReactJS app to show there. I know I need to do some configuration but somehow not able to find what's the right way of doing it. I have nothing installed on my Ubuntu server except NodeJS and npm.
Any suggestion will help me.
Thanks
For pure Node.js solution, tou can use static files (HTML/JS/CSS) HTTP server like following
https://github.com/cloudhead/node-static
https://github.com/indexzero/http-server
I've used http-server which is super simple and can be installed as a CLI tool as well

Can I run VueJS and NodeJS or related apps on Server that doesn't have NodeJS installed?

So I'm new to Vuejs and doesn't know anything about npm, node, and other javascript apps.
I wanted to switch to VueJS so that I can take away from JQuery. Been using AdminLTE for my projects before.
I wanted to use vue-admin now since it seems to address all of my needs. However, I have specific work area situations that seems to hinder learning Vue and other JS apps, these are:
The workspace folder (development) where I'm creating applications is hosted in the production server (Windows Server).
I think NodeJS isn't installed in the server
Adobe Coldfusion is used. I don't have a local server, so the production server is used when developing.
Question:
Will the production server run the app built with vue-admin even if the production server doesn't have NodeJS installed? (I have NodeJS locally).
I need to use Coldfusion for the logic of the application, specifically I'm using CFWheels right now and vue-admin for Frontend and UX. Is it possible? The application I'm making is closely related to parts of an ERP system.
Any pointers on how I could do this?
Yes you can. Most likely you will need NodeJS locally to make your development life a bit easier.
You can simply include Vue in your project with a script tag or your can use a buildtool like Webpack to enable you to write ES6 and use a module system.
If you go with the latter it still exports as plain ES5 allowing you to use it on your server without any problem since all of this is code which runs on the clients machine, not on your server.
As you can see the requirements for this project have a big bold headline with: 'Development'.
https://github.com/vue-bulma/vue-admin#development
You don't need any of the requirements in production.

Resources