All Questions
Tagged with server javascript
1,991
questions
184
votes
17
answers
627k
views
npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\Nuwanst\package.json'
I just want to install socket.io to my project which is located on 3.chat folder. But when I run following command it shows following Warnings.And its not created a node_modules directory inside my ...
57
votes
15
answers
105k
views
Missing credentials for "PLAIN" nodemailer
I'm trying to use nodemailer in my contact form to receive feedback and send them directly to an email. This is the form below.
<form method="post" action="/contact">
<label for="name"&...
52
votes
19
answers
111k
views
keep getting "? Something is already running on port 3000" when I do npm start on react app
I keep on getting "? Something is already running on port 3000" message in my terminal when I start up my react server when there is absolutely nothing running on my port 3000
What I have ...
41
votes
2
answers
36k
views
Multipart HTTP response
The goal is for a Node.js / hapi API server to respond to a browser's AJAX request with two things:
A media file (e.g. an image)
A JSON object with metadata about the file
These are two separate ...
38
votes
1
answer
22k
views
What does the command "node ." do?
The README document of my node server instructs me to run this command on my command prompt.
node .
What does this command do? How does it start my node server?
My package.json contents are
{
"...
35
votes
1
answer
34k
views
new URL() - WHATWG URL API
I'm messing around with node and I'm trying to get an instance of the URL class (because of those handy properties). Like:
const { URL } = require('url');
(...)
http.createServer((request,response) =&...
30
votes
1
answer
62k
views
Node.JS Error- process.env.NODE_TLS_REJECT_UNAUTHORIZED. What does this mean?
I am new to back-end development. And I am really enjoying writing code in node. However, there are few things I just can't seem to grasp. I kept getting the following error:
Error: ...
18
votes
3
answers
14k
views
How Server Sent Event send response to a specific client
In Server Sent Event, it always send the same response to all the client. but what i want to know is, How to send response to an only one client using java.
this is my event which define inside sw.js ...
17
votes
9
answers
8k
views
Why is server ignoring changes in the code files even though cache is disabled?
I test an html/js code on my localhost (Windows 7, Chrome v79.0.3945.130 (64-bit)) and about 50% of the time code changes are not reflected in the browser (I see it with Dev Tools/Sources).
There are ...
16
votes
3
answers
9k
views
Difference between Localhost and opening html file
What is the fundamental difference running a file using a server in localhost, and opening a file such as file:///Users/$user_name/$your_directory/index.html, assuming no backend is used, and it is ...
16
votes
3
answers
14k
views
Server Side Implementation of requestAnimationFrame() in NodeJS
I have some questions regarding the wildly used requestAnimationFrame() functions. Recently I came across some implementation in multiplayer games who used it on the client instead of the server side.
...
15
votes
4
answers
7k
views
What is the difference between React Server Components (RSC) and Server Side Rendering (SSR)?
So with React 18 came RSC. I'd like to how is it different from SSR we have in NextJS.
14
votes
3
answers
50k
views
Easiest way to get list of files in the server directory
I need to get array of all images (or simply of all files) in directory (e.g. www.example.com/images/). I prefer to use JavaScript but it's hard to make. So should I use PHP, meybe?
Could you please ...
13
votes
2
answers
31k
views
Node, Express - CANNOT GET route
I am building an Express app and having some issues with routing. My '/' route is working perfectly, however other routes are not. I've looked into other questions people have posted and these have ...
13
votes
4
answers
41k
views
TypeError: require(...).listen is not a function
I wrote this, but errors come up and i dont know how to fix
var http = require('http');
var clientHtml = require('fs').readFileSync('client.html');
var plainHttpServer = http.createServer(function (...
12
votes
1
answer
41k
views
WebSocket connection to 'ws://localhost:3000/' failed: Connection closed before receiving a handshake response
I took a game that my friend made and wanted to make it playable across browsers by sending keypress data between peers with WebRTC and websockets. However, I get this error in the console:
...
12
votes
3
answers
13k
views
How to properly close a Node.js TCP server?
I couldn't find a clear answer on Google or SO.
I know a net.Server instance has a close method that doesn't allow any more clients in. But it doesn't disconnect clients already connected. How can I ...
11
votes
5
answers
24k
views
Running svelte dev on server
I am running svelte like this on my server:
$ npm run dev
Your application is ready~! 🚀
- Local: http://localhost:5000
────────────────── LOGS ──────────────────
Which is great. However, ...
10
votes
2
answers
2k
views
Redirecting using "pure" Node.js from inside a callback function
The following is an MCVE of my server.js code:
let fs = require('fs');
let http = require('http');
http.createServer((req, res) => {
// Handles GET requests
if(req.method == 'GET') {
...
10
votes
1
answer
5k
views
Express: Is it necessary to respond with status 200?
Is it necessary to respond with a status 200 code or is it the default behavior?
response.json({
status: 'OK',
});
vs.
response
.status(200)
.json({
status: 'OK',
});
When I hit the ...
10
votes
3
answers
6k
views
Best approach for auto save on-change
I want to remove the "save" button and auto-save changes live.
The way I know this can be done is by using the OnChange function.
Baring in mind that the web application will be used by quite a ...
9
votes
1
answer
6k
views
navigator.credentials is null on local server
here is my problem : I try to use the Credential Management API to access to authenticators on my webapp :
navigator.credentials.create() and navigator.credentials.get().
I have no problem when I ...
9
votes
4
answers
2k
views
Safari does not run callback function on refresh/onbeforeunload on server side (calls client side code)
I am trying to send some requests to the database when the window is unloaded (i.e. when you refresh the page). For some reason, only on Safari, the client side code gets executed, but the request to ...
8
votes
5
answers
21k
views
404: NOT_FOUND on Vercel deployment
I have build a web3 application using chakra-UI and three.js. I have added a metamask integration to the website, which helps to mint the NFTs on smart contract.
When I do,
npm run dev
On my machine, ...
8
votes
1
answer
10k
views
This site requires Javascript enabled in your browser
I Need to download some files from Server
I use Retrofit ,Voelly and DownLoadManager which are some of ways to download files from server in android , but my response is not the things that I want .
...
8
votes
2
answers
12k
views
Nuxt.js problem with server-side API call with https
I have problem with nuxt server-side API call when im using HTTPS. On client side everyting is fine and API works when im switching pages on client side via links, but when I hit Ctrl + f5 and data ...
8
votes
2
answers
477
views
Requests to non-existing pages that all include "undefined”
Some odd requests appear on our logs since ~October 20, 2014. They've increased to about a few dozens a day so while not a big problem, it's still interesting to find out the reason.
Earlier ones:
...
7
votes
2
answers
5k
views
How to avoid Hapi.js sending 400 error when Validating Request with Joi
Hapi.js Validation with Joi + failAction question.
Situation
We want to build a "traditional" server-side-only
rendered application using Hapi.
I'm trying to understand how to avoid returning a "...
7
votes
1
answer
4k
views
Memory usage doesn't decrease in node.js? What's going on?
I am tracking the memory using task manager and my app is a webrtc app using socket.io.
So when I track the memory and open localhost, connect two browser windows, it obviously adds a little bit of ...
7
votes
1
answer
3k
views
Start nodejs app that use cross-env with pm2
I'm trying to start my nodejs app, the default cmd is the following :
pm2 start app.js
I can't do that because I use cross-env and the script as below:
"start": cross-env DOTENV_FILE=.env node ...
7
votes
1
answer
10k
views
Socket.io using node.js with no express at all?
So I want to create a node.js server using socket.io, but I am more of a beginner, and find the express package rather confusing syntactically. I know that I should learn how to use express and app.js,...
7
votes
2
answers
12k
views
Download Excel file in xlsx format using Javascript (exporting html tables into Excel)
I am using JS, HTML and CSS to build my application and host it on a server. I am using the following code to import all the html tables to an excel file in xls format.
function fnExcelReport(...
6
votes
2
answers
5k
views
MMO WebSocket Server: Node.js or C++?
I have been thinking of making a real-time game with WebSockets for the web. I know how to use Node.js, and it is tempting to make it on there. But everywhere I look, C++ seems to be the popular ...
6
votes
1
answer
9k
views
Generate JavaScript file with PHP when requested in HTML
How do I Generate a JavaScript file with PHP when it is requested in an HTML program? I want a PHP program like this that runs on the server when a certain JavaScript file is requested. Example code:...
6
votes
4
answers
6k
views
How to run Typescript files on Server in background?
I have a NodeJS application which has only typescript files in it, no js files. I want to run in on my server in the background.
How can I archive that?
I tried using the npm package called forever ...
6
votes
6
answers
25k
views
nodemailer Invalid login: 535 Authentication Failed
I'm trying to use nodemailer(npm package) in my node app to send email through the contact page. It is giving me this 535 Authentication Failed error while I can assure you that my email and password ...
6
votes
1
answer
9k
views
Possible to bypass Heroku's free plan's "Sleeps after 30 mins of inactivity" with console.logs?
Heroku has a free plan, as outlined here: https://www.heroku.com/pricing
One of the drawbacks of the free plan is that the server goes to sleep after 30 minutes of inactivity. Is it possible to bypass ...
6
votes
2
answers
8k
views
Calling a Node.js server with Vue.js
I have a simple Node.js server up and running. This is the code:
var http = require('http');
var server = http.createServer();
server.on('request', function(req, res) {
res.writeHead(200, {
...
6
votes
1
answer
4k
views
Can someone help me with this "Argument `where` of type UserWhereUniqueInput needs at least one of `id` arguments." error?
i put this console log here to see whats receiving:
{
username: 'aa',
gender: 'Feminino',
cargo: '2',
email: 'a',
password: 'a'
}
this is the error message Ive been encountering:
Prisma client error: {...
6
votes
2
answers
19k
views
How to see whether a website is client side rendered or server side rendered?
So, SSR means that the server sends a fully packed html, css and js file while CSR only sends the empty html and again client fetches the js to populate the data on the page.
I want to visualize this....
6
votes
1
answer
4k
views
Is it possible to open a port in Javascript for communication on the network?
I saw that Socket.IO and Websockets usually require NodeJS or similar but don't run on clients.
Is there any possible way to open a port for accepting communications using JavaScript? So devices can ...
6
votes
1
answer
3k
views
Restrict access to Node.js using Express
I do have a running node.js script located in a server.
What i want is that it doesn't get directly accessed from browser and also i want that only certain domains/IP-s can call it!
Is it possible?!
6
votes
0
answers
302
views
Listening on Same Host and Port Twice Does Not Trigger an Error
const http = require("http");
function createServer(
name,
hostname
)
{
const server = http.createServer(
(
request,
response
) =>
{
console.log("request on", ...
5
votes
5
answers
8k
views
nodemon - Internal watch failed: ENOSPC: no space left on device, watch '/home/user/Documents/github/sendMail-lib/3808.txt
I am getting an error while running my server file using nodemon. When I type the command nodemon, I get the following output.
[~/D/g/sendMail-lib|3.6.5]
‹master*› »»»» nodemon ...
5
votes
2
answers
8k
views
How to use javascript type="module" locally in browser [duplicate]
I was working on a project with a local server.
In this project, i'm using modules, so my index.html contains:
<script src="js/index.js" type="module"></script>
...
5
votes
3
answers
8k
views
Get the number of Requests in Express
I would like to know if is there any way of getting the total number of request in a certain path with Expressjs?
5
votes
1
answer
9k
views
WebStorm built-in web server gets 404 for every css and js file included in index.html
Here is my index.html for posterity's sake:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<...
5
votes
1
answer
15k
views
Nodejs : ReferenceError: express is not defined [closed]
I begin to use Nodejs to create web servers, and for this, I use express module. Then, I intalled it with command : "sudo npm install -g express".
But after lanched the program, this error occured :
...
5
votes
4
answers
12k
views
Node JS not listening to port 1337 on server
I'm trying to open a port on particular lamp server hosted by Google and I'm in connection with the server via ssh.
I've followed this link to configure nvm and the latest Node JS(v0.12.5) on it. ...
5
votes
1
answer
1k
views
Do I need to import the process module of nodejs or leave it as such?
I've seen that the process modules can be used without importing it directly in your file as said in the documentation from 2011. https://nodejs.org/en/knowledge/getting-started/the-process-module/
...