Most voted "node.js" questions
Node.js (or commonly Node) is a Javascript Runtime created with Chrome’s Javascript V8 engine. It allows you to run Javascript code without the need for a browser, raising the privileges to those found in other desktop languages. It is a technology strongly focused on non-blocking programming of I/O operations, which makes it very efficient for these operations.
Learn more…2,679 questions
Sort by count of
-
2
votes2
answers142
viewsDocker: Problem using container IP
Hello, All right? Before long I learned to use Docker and decided to practice the use of mysql and adminer, with the following Docker-Compose I already had the containers standing. version: '3.5'…
-
2
votes1
answer41
viewsHow to get each item of an XML?
In my Node.js application, I have this answer in XML: <?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?> <checkout> <code>meucode</code>…
-
2
votes0
answers36
viewsWhat is the difference between defining an object property as a function or already passing the direct parentheses?
What is the difference between store and store2 properties? const MyObject = { store1(req, res) { console.log(req, res) }, store2: function(req, res){ console.log(req, res) } }…
-
2
votes1
answer383
viewsProblem when removing all attributes of an object containing null values
Context I’m inside an application in Nodejs, where I have a very large object that has various attributes and also attributes objects that have children, and I have a situation where I can’t keep…
-
2
votes1
answer102
viewsHow to request user input in Node.js?
I’m having trouble using the function prompt on Node.js. I intend to receive the value a user wants for verification and resolution of my code. But, when running the code, I get this error:…
-
2
votes1
answer65
viewsHow to extend a global method in tests using globalThis?
I’m making a node.js exercise, but the version I’m working on is younger, and has now adopted the globalThis in the instance global. import { SetupServer } from "./server"; import supertest from…
-
2
votes2
answers1326
viewsError when connecting mysql instance with nodejs
I raised with Docker mysql container docker run --name mysql-docker -e MYSQL_ROOT_PASSWORD=password -d -p 3306:3306 mysql But when trying to connect via Node node index.js the following error occurs…
-
2
votes2
answers1568
viewsTaking absolute path from relative on Node
I have a problem reading files in a code that is the following: src/race.js import { readFileSync } from "fs"; import { resolve } from "path"; export function readFile(path) { const absolutePath =…
-
2
votes1
answer158
viewsHow to receive the result of an asynchronous function and move to Return?
I have the following code in nodejs in a lambda function in AWS that has been defined using serverless. The goal of this function is to read a URL that will return an XML, transform into JSON and…
-
2
votes1
answer259
viewsHow to upload an image to Nodejs?
Good afternoon, I want to make a POST Request of the client in JAVASCRIPT with DATA Send (file . jpg) in date URL for the NODEJS server. [Client] - Javascript finalImg.onload = function(event){ var…
-
2
votes1
answer479
viewsProblems with Bodyparse on Node.JS using Express (data like POST)
Hi, guys! I am starting my studies in Node and React-Native and I am facing some problems in data transaction in front POST method for my API. I had a similar problem with headers, but I was able to…
-
2
votes1
answer135
viewsNodejs: How to keep an updated list accessible between files
In a Nodejs application with Express/EJS, I need to keep an updated list and I would like that whenever the user accesses my root route, that is the INDEX page, he could see this updated list. To…
-
2
votes2
answers1815
viewsDownload files in API Restfull Nodejs
I have an API I made based on a tutorial, where I can upload files: Server.js var express = require('express') , app = express() , bodyParser = require('body-parser') , multiparty =…
-
2
votes1
answer50
viewsReturn database value to e-mail
Hello! I have a question here, I’m doing a function that takes the data from the Database and sends an email with them, for example: 'Hello {{Name}}'. ({{Name}}) It would be the field that would…
-
2
votes0
answers67
viewsNot loaded server style in Node.js application
I have a question. I’m using the github pages to develop a website using Node.js. In my host, styles load and I can view them normally in the browser. However, when I try to see the application to…
-
2
votes1
answer154
viewsWeb application with React making infinite requests
export default class Usuariobox extends Component{ constructor() { super(); this.state = {lista: []}; } componentDidMount(){ this.Listar(); } Listar(){…
-
2
votes1
answer254
viewsElectron error using "escpos" and "Electron-rebuild": not a valid Win32 application
I am developing a desktop application with Electron and I have the following problem when trying to run the application on Windows: All this started after I installed the framework "escpos" to work…
-
2
votes1
answer206
viewserror when connecting mysql with Node.js
am connecting mysql with Node but is giving this error: C:\E. S\dao.js:10 if (err) throw err ^ Error: getaddrinfo ENOTFOUND localhost:806 localhost:806:3306 at GetAddrInfoReqWrap.onlookup [as…
-
2
votes2
answers548
viewsHow to use Mysql SELECT + WHERE + IN with Javascript array?
How can I perform the following SQL query by passing a Javascript string array? SQL query performed in Mysql - status OK: SELECT * FROM tab_price_list AS PL WHERE PL.PartNumber IN ('HDW00008.ELEM',…
-
2
votes1
answer267
viewsHow to optimize a Node.js script
Hello, I would like the help of users to optimize a script I made in Node.js. I do not understand much of the language and I made a very amateur system that is a little slow. var express =…
-
2
votes3
answers209
viewsUndefined return when calling function
The console.log(Return) is ok, but only Undefined’s return, could anyone tell me why? let result = []; module.exports = { async atualizar() { await request(url, (err, res, body) => { if (err)…
-
2
votes1
answer59
viewsIs there any way to import a dependency into an object? NODE.JS
I’m developing an Electron application together with Node.js, and I can’t import a dependency within an object. You can do this, import a dependency into an object? const conexao = { **//Acredito…
-
2
votes1
answer649
viewsError: NJS-047: poolAlias "default" not found in the Connection pool cache
I’m trying to make a connection using Connection Pool to build a API Nodejs consuming data from Oracledb, I followed the following documentation. However, when trying to make the connection I get…
-
2
votes1
answer84
viewsIs there a problem using objects like this in Node.js?
I’m working on a system that contains a simple CRUD for tables from a Postgres database, in which new tables can be added eventually. So to avoid rewriting the controllers all the time, I did the…
-
2
votes1
answer213
viewsTreating error in callback function
I’m trying to fix a mistake in the following code: const fs = require('fs') fs.readFile('dados/arqui2vo.json', (err, data) => { if (err) throw new Error(`Can't find the file`) When I run the…
-
2
votes1
answer49
viewsError using async in Nodejs
I have a system in Nodejs in development and finished a step, for the purpose of testing, I put it on a server and from that began to return me error in all lines of code in which I used the async…
-
2
votes1
answer721
viewsQuestions about Authentication Token (JWT)
For a while I used the Json Web Token (JWT) to do the entire authentication process of most systems on which I work on Node.js. But today, developing one of my personal projects, I took a look at…
-
2
votes1
answer101
viewsHow do I make appends on Mongoose models?
I have a model in Mongoose that references another model, and I need to bring the data of this other model in my controller, follow code: Model Empresa.js: 'use strict'; const mongoose =…
-
2
votes0
answers606
viewsConnection error at EXPO
Some of you, like me, must have done last Omnistack Week. I am having an error when connecting my back-end Login route in my front-end. I am using the axios for that. When I give a yarn start or…
-
2
votes1
answer1334
viewsFilter an object array within another object array
I have an array like the one below and would like to filter it by the property that is inside an object inside an array that is inside another object. The idea would be to return all objects whose…
-
2
votes1
answer89
viewsUser Creation Api Is Returning Status 204 In Content
I’m developing an api that I get the id the user of the request through the token, I store in my user object and I register this user. The problem is that it is not returning anything, even if I put…
-
2
votes0
answers152
viewsCalling Javascript file using Express
I have a main.js file with routes to html files, but I would also like to add a route to a javascript file. In the main.js file I have the following code. const express = require("express"); const…
-
2
votes3
answers120
viewsProblem with javascript filter in various JSON
I’m trying to capture a certain product for your ID using the filter but there are some problems. It is only returning an empty array. The products are stored within Categories, that is, there is an…
-
2
votes1
answer455
viewsFlutter does not return images from api
I’m trying to get the images from mongodb database, via api I did in nodejs, but it doesn’t work at all, and still presents this error here. Invalid argument(s): No host specified in URI…
-
2
votes1
answer402
viewsHow to change pages through nodejs?
Well, I tried to switch pages hit the login button, but I get this error: "path must be absolute or specify root to res.sendFile". My folder structure: HTML form (index.html): <div…
-
2
votes2
answers709
viewsHow to get the connection id of a socket on a js Node server?
Hello, I am studying sockets with Node js for games and I would like to know how to recover the id of a client socket connection with the server, I have tried several ways but did not succeed! My…
-
2
votes1
answer345
viewsWhy does the express session return 'Undefined'?
I’m having trouble recovering data from req.session. I have a sub-router that manages the main route and use a middleware to manage the session. I add the data I want to record in the session, but…
-
2
votes1
answer132
viewsFs.readFile dropping server
I’m using a server node.js with express and created an API to record content that arrived via POST in an archive .json. It does the process correctly to a certain extent: If the file does not exist,…
-
2
votes1
answer339
viewsDoes the Eslint option of "enforce code style" add any behavior when we are already using Prettier?
When we perform eslint --init, we first come across the following question: I performed two tests, one selecting "To check syntax and find problems" and other using "To check syntax, find problems,…
-
2
votes3
answers1566
viewsWhy doesn’t Node.js run sucrase - a locally installed package?
On Node.js, I installed on cmd the yarn (I can’t use the yarn and I’m using the npm), but it doesn’t work. I chose to use npm and now when trying to use the succrase library (install: npm install…
-
2
votes1
answer4302
viewsHow to perform data validation using Yup with custom locale?
I’m trying to add input data validation to a small script I built using Express, the validation part is using Yup. I’m having a hard time organizing things because of the need to work with a custom…
-
2
votes0
answers20
viewsMongodb collections
I have a database in Mongo with the following collections "Productsservices" and "stock" where the stock collection will inform the stock value of a record within the product and service collection…
-
2
votes1
answer79
viewsGrouping objects of an array by equivalent dates
Good morning, I have a question where I have an array of objects as follows, for example: var producao = [{data: '2019-12-19', producao_ok: 10, producao_nok: 20}, {data: '2018-10-01', producao_ok:…
-
2
votes1
answer49
viewsWeb Scrapping Nodejs - I cannot use variable as parameter
I’m using the library Nightmare, for Web Scrapping, function works normally when I pass a string as parameter '.seletor', the problem occurs when I store this value in a variable and step as…
-
2
votes1
answer1598
viewsError doing GET search with queries
Hello, I created in my application a GET wheel /search, but when I try to send a request with queries by the Inuit application, the node terminal returns two errors, the first is: Typeerror: Cannot…
-
2
votes1
answer283
viewsres.render does not load . handlerbars within route - Node.JS and Handlerbars
Good night! I’m learning Node.JS and I’m stuck on the routes. I have the following codes. //app.js // carregando modulos const express = require('express') const handlebars =…
-
2
votes1
answer536
viewsHow do I set a default value for a column in Sequelize?
I am using Sequelize (v5.0+) with Nodejs (with Express). I want that for the column status in my database has the default value (defaultValue) as true. Migration module.exports = { up:…
-
2
votes0
answers218
viewsUse a Controller to connect routes with asynchronous functions [Node]
Good night! I’m having doubts about something that seems easy, but I’m not getting out of place. The idea would be to utilize the GET method to recover users from the database, but would like to use…
-
2
votes2
answers122
viewsarray.push() inside mysql.query callback (nodejs)
Hello, I am having a problem adding a custom error in an array of errors, in the validation of a form with nodejs. I’ve tried to change my approach but I haven’t found a solution, //PARTE 1 let…
-
2
votes0
answers298
viewsValidating a nested and conditionally optional Yup scheme
I am facing a problem when trying to validate a scheme nested with Yup (). My scenario is that I have the following payload (which may not always contain maxAge and maxAge, but at least one of…