Skip to content

1. NodeJS

Node.js has revolutionized server-side development, empowering developers to build scalable, high-performance web applications with JavaScript – the language of the web. In this wiki, you’ll find a wealth of resources covering a wide range of topics, from the basics of asynchronous programming and event-driven architecture to advanced techniques like building RESTful APIs, microservices, and real-time applications.

  • A runtime environment to execute JavaScript outside the browser.
  • Built on Chrome’s V8 JavaScript engine.
  • Uses event-driven, non-blocking I/O.
  • Web servers
  • RESTful APIs
  • Real-time applications (e.g., chat)
  • Install from nodejs.org
  • Verify with:
    Terminal window
    node -v
    npm -v
Terminal window
npm init
const http = require('http');
const server = http.createServer((req, res) => {
res.write('Hello from Node.js server!');
res.end();
});
server.listen(3000);

You can handle simple GET and POST requests using just Node.js and the http module — no Express needed.

const http = require('http');
const server = http.createServer((req, res) => {
const { method, url } = req;
// Set content type
res.setHeader('Content-Type', 'application/json');
if (method === 'GET' && url === '/') {
res.writeHead(200);
res.end(JSON.stringify({ message: 'Hello from GET!' }));
} else if (method === 'POST' && url === '/data') {
let body = '';
// Collect the POST data
req.on('data', chunk => {
body += chunk.toString();
});
// Handle end of data
req.on('end', () => {
const parsedData = JSON.parse(body);
res.writeHead(200);
res.end(JSON.stringify({
message: 'Received POST data!',
data: parsedData
}));
});
} else {
res.writeHead(404);
res.end(JSON.stringify({ error: 'Not found' }));
}
});
server.listen(3000, () => {
console.log('Server running on http://localhost:3000');
});
  • GET request:
    Visit http://localhost:3000/ in your browser → responds with JSON.

  • POST request (e.g. using curl or Postman):

Terminal window
curl -X POST http://localhost:3000/data \
-H "Content-Type: application/json" \
-d '{"name":"Nadith", "age":17}'

================================

Removing Node

To uninstall Node.js from aaPanel, follow one of the methods below depending on how you installed it:


✅ If You Installed Node via aaPanel App Store:

Section titled “✅ If You Installed Node via aaPanel App Store:”
  1. Go to aaPanel > App Store
  2. Scroll or search for Node.js
  3. Click the “Bin icon” (Uninstall) next to Node.js

This will cleanly remove Node.js and any linked paths managed by aaPanel.


🧨 If Node.js Was Installed Manually (via source, NVM, or apt):

Section titled “🧨 If Node.js Was Installed Manually (via source, NVM, or apt):”

You need to remove it manually depending on the method:


🅰️ APT-based Uninstall (Debian/Ubuntu)

Section titled “🅰️ APT-based Uninstall (Debian/Ubuntu)”
Terminal window
sudo apt remove nodejs
sudo apt purge nodejs
sudo apt autoremove

If you used nvm:

Terminal window
nvm uninstall <version>
# Example:
nvm uninstall 18

Or to remove all:

Terminal window
rm -rf ~/.nvm

Also remove from .bashrc or .zshrc:

Terminal window
# Remove lines like these
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

🆎 Remove Global Folders (Optional Clean-Up)

Section titled “🆎 Remove Global Folders (Optional Clean-Up)”
Terminal window
sudo rm -rf /usr/local/bin/node
sudo rm -rf /usr/local/bin/npm
sudo rm -rf /usr/local/lib/node_modules

Run:

Terminal window
node -v
npm -v

If they show “command not found”, Node.js is fully removed.