This might be a stupid question, but can I setup node.js to run an environment like WAMP? Just to test html docs, JavaScript, Json and Ajax requests.
If this is a good idea or possible, anyone have an advice on setting up the file structure?
You're misunderstanding some Node.js fundamentals. Let's break this down...
WAMP
W - Windows
You can install Node.js on Windows here. Nothing special.
A - Apache
While you can put Apache in front of node as a load balancer, for development purposes it's likely unnecessary. Node.js doesn't need Apache, or nginx. It will happily serve HTTP responses all on its lonesome.
M - MySQL
Sure, use MySQL if you want. :) You'll want to install MySQL on your machine, then you can get a driver for it on npm: https://www.npmjs.com/package/mysql
P - PHP
Node.js doesn't run PHP (barring a few most unholy abominations). Try taking a look at Jade.
The Basics
After you get Node.js installed, I'd recommend taking a look at Express and Jade. Start with the Express hello-world. You can run it simply by opening a command line, navigating to the project directory, and running node hello.js (or whatever you named the file). Just like that, you'll be serving HTTP requests. No need for a "stack".
Related
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.
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
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
I installed node.js on linux server. I'm able to run node.js on command line, but not able to run on browser.
Did I clearly explained what I want?
I have a domain ram.com that point to particular location on my server /var/www/html/ram.com/.
I created node.js pages on this location /var/www/html/ram.com .How can I access this page on browser?
My apache running on 80 port. Can you explain any changes in apache configuration?
I'm new to node.js can you explain clearly.
To use Node.js to serve your website, you just need to type node yourFileName.js in command line to start the server.
I don't really know how your pages look like. You need *.js files as Node.js source files, and Node.js work as backend. If you mean *.html, you can access them when the server program is running.
Actually, Node.js has its own built-in web server, just like PHP + Apache. So you don't need to use Apache, and I don't think Node.js and apache can work together without other tools.
This is my first answer in Stack Overflow, hope that can help you.
this might be a bit of a silly question but it's something that i've been struggling to find the answer to and for some reason it doesn't seem to be evident from the tutorials and websites i have been reading, so maybe it's something that is assumed that i'm really missing.
So anyway, i installed node.js and then used the command npm install socket.io. it them proceeds to download and install a bunch of files, i don't see any error with this process in the command line.
So now i've tried to access socket.io like this:
<script src="/socket.io/socket.io.js"></script>
Like it shows on the socket.io website, however i get an error saying the file isn't found..... my first guess is that the installation of node.js and stocket.io are both on the local machine (program files) and not in the htdocs.
I have tested this one two platforms, first was my localhost which is Windows 7 running XAMPP on it, and i installed node.js and stocket.io globally (Program files). Second was my Windows server that uses IIS still get the error.
So my question is, how do i reference the stocket.io API and start using it based on the installations i have?
Thanks for your time.
npm isntall socket.io installs Socket.IO in a local node_modules folder so that the library is accessible to you in your own Node.js applications. You still need to create (and run) a Node.js application that loads up the module and sets up an HTTP server that uses the module; the examples under How to use in the project readme is a good starting point, although preexisting knowledge of Node.js will be helpful. You might check out Node.js Tutorial with Socket.IO if you're looking for additional information.