0
Ok, so how exactly start writing nodeJS code
I have a website running (hosted with Namecheap shared plan). I [create, update,] content frequently. To do that I use cPannel > File Manager to manually edit html [the file I need to /edit]. It’s kinda an okay way to update your content if you don’t got a choice, but upon doing some research, using Templating Engine is the way to do it. They say dJango is the best, but I’m going with NodeJS, since I’m familiar with JS. I learned to install nodeJS (on local computer), and display hello world.
12 Respostas
+ 6
Looks like this might address that, even though the English is a bit wonky.
hoststud.com/resources/how-to-create-a-node-js-application-with-cpanel-using-the-node-js-selector.730/
Cpanel does have its good aspects but I'm glad I don't have to deal with it daily anymore.
+ 4
NodeJs is the way to run Javascript outside browser using Google V8 engine
Google for any MERN/MEAN stack (Mongo + Express) boilerplate
https://expressjs.com/
Its easy to learn since Mongo has the Mongoose driver and its a json database.
Some basic tutorial
https://auth0.com/blog/developing-well-organized-apis-with-nodejs-joi-and-mongo/
For anything more advanced/enterprise I recommend you search some ORM framework and use Typescript instead of Javascript
https://expressjs.com/en/resources/frameworks.html
Also read some tips about performance and clustering
+ https://expressjs.com/en/advanced/best-practice-performance.html
+ https://dev.to/joan41868/scaling-a-simple-node-js-express-js-application-using-node-js-modules-23bp
+ https://nodejs.org/api/cluster.html
+ 2
https://bhattaraipradip66.medium.com/how-to-deploy-a-node-js-application-through-cpanel-891ed374225a
+ 1
In the web host, in the file cPannel, there’s an option “Create nodeJs application”.
I created the application, but now what?
Like... how can i write some code (node.). So i can make an api which i can use to edit/create content on my site
+ 1
```js
const http = require("http");
const app = http.createServer((req, res) => {
if(req.url === "/") {
res.write("hello");
res.end();
} else {
res.write("404: page not found") ;
res.end();
}
});
const port = process.env.PORT || 5000;
app.listen(port);
```
This is with vanilla js.
We often use express to create server.
```js
const express = require("express") ;
const app = express();
const port = process.env.PORT || 5000;
app.get("/", (req, res) => {
res.send("hello");
})
app.listen(port);
0
Phil Andy Graves so, what are you using now?
0
Ginfio mostly command line when I do anything with node (have some interesting mobile stuff) but I'm working on ecma stuff at the moment instead of node. If I were starting over knowing what I do now, I would be using adb and termux, then install the termux desktop.
0
Here are some books that can help you start coding Node.JS once you've got the basics down, you can just begin picking away at things until you've learned the language.
https://mmcgbl.com/node-js-development-company/
0
Node.js Get Started
myfirst.js. var http = require('http'); http. createServer(function (req, res) { res. writeHead(200, {'Content-Type': 'text/html'}); res. end('Hello World!' ); }). listen(8080);
C:\Users\Your Name>_
Initiate "myfirst.js": C:\Users\Your Name>node myfirst.js.
Regards,
Rachel Gomez
0
Node.js: Node.js is a JavaScript runtime that allows you to run JavaScript on the server-side. It's a popular choice for building web applications and APIs. Since you're already familiar with JavaScript, using Node.js can be a good option.
Templating Engine: Templating engines help you generate dynamic HTML by combining templates with data. There are various templating engines available for Node.js, such as EJS, Handlebars, Pug (formerly Jade), and Mustache. Choose one that fits your preferences and requirements. https://www.upsers.app/
Setting up Node.js on your server: Since you're using a shared hosting plan with Namecheap, you may need to check if Node.js is supported. Shared hosting plans often have limitations or specific configurations for running Node.js. Contact Namecheap support or consult their documentation to confirm the compatibility and setup process for Node.js on your specific hosting plan.
Development and testing: As you mentioned, you have already installed Node.js on your local computer and displayed a "Hello, World!" message. This is a great starting point. You can now begin developing your website locally using Node.js and the chosen templating engine. Test your website locally to ensure it works as expected.
0
To start writing Node.js code, first, ensure Node.js is installed on your system. Then, create a JavaScript file with a .js extension, open it in a code editor, write your Node.js code using JavaScript syntax
, and save the file. You can execute the code by running node filename.js in your terminal, where filename.js is the name of your JavaScript file.
- 2
I need explanation on this please
Console.log("2">"12)
Ans = true