Questions tagged [node.js]

Node.js, powered by Google's innovative V8 JavaScript engine and libuv library, is an exceptional runtime environment. Embracing event-based architecture, non-blocking operations, and asynchronous I/O, it empowers developers to seamlessly execute JavaScript on both client and server sides. This distinctive feature grants applications the advantages of code reusability and eliminates unnecessary context switching.

Can a Sequelize table be joined without a defined relationship?

My findings indicate that the solution is not obvious. Let me provide a brief example of what I aim to achieve. We have 3 tables: Company, Product, Lookup... The Company table has multiple Products associated with it while each Product belongs to one Com ...

Enhance your Sails.js model by incorporating a custom instance method as a new property

As a JavaScript programmer still learning the ropes, I encountered a challenge while working with Sails.js and creating a model. Here is what I have so far: module.exports = { tableName: 'FOO_TABLE', attributes: { FOO: 'st ...

Error encountered with CORS in a Socket.io Express HTTP server backend

While developing an app that utilizes express for the backend, I decided to incorporate socket.io for real-time chat functionality. Everything was working flawlessly on postman until my front end react code triggered a cors error when making a GET request ...

Node.js - Error: Undefined:0 SyntaxEncountered an unexpected end of input syntax error

Exploring Node.js and Backbone.js for the first time. Using the book "Backbone Blueprints" but encountering issues with the provided code to set up the webserver. Node.js is installed and running fine. Here's the package.json code: { "name": "simp ...

Issues with displaying images have been encountered with the Chessboardjs NPM package

Currently, I am attempting to utilize the https://www.npmjs.com/package/chessboardjs package in conjunction with meteor 1.13. Despite developing a simple react component to display the board, the images are not rendering as expected. Below is the code for ...

Error: Unable to locate named export for 'express'

I am facing an issue with my CRUD project developed using react and nodejs. When I attempt to run index.js, a strange error pops up: Named export 'express' not found (please refer to the image for details). The code in my index.js file is as fol ...

You must use the 'new' keyword in order to invoke the class constructor

Although similar questions have been asked before, my situation differs from the typical scenarios. I have a basic base class named CObject structured as follows: export class CObject extends BaseObject { constructor() { super(); } sta ...

Exploring the installation directory for modules in Node.js and npm

After utilizing Node.js and npm for a few weeks with success, I've begun to question the best practice for installing local modules. Despite understanding the Global vs Local argument, my concern is more about where to store a local install. For example, i ...

Obtaining Font Information using Node.js

Is there a way to retrieve the Description section of a font's properties, as seen when you right-click on the file? https://i.stack.imgur.com/rwnLw.png I am specifically looking for details related to the Title attribute. I tried using the get-file-pro ...

Every time I open my browser, my Node.js web app creates a fresh session

Whenever I close all browser windows and reopen the web app, a new session is initiated, forcing me to re-authenticate each time. To give you an idea, my web application framework is <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfema ...

What is the process for updating the Git Hash in a npm package.json within a Git project?

Is there a way to specify an exact git hash in the dependencies of a Github project's package.json, while also making it easy to upgrade at a later time? Here is how my current package.json looks: { "name": "my fabulous app", "version": "1.0.0", "d ...

The command 'npm-run-all' is not valid and cannot be found, please check the command and try again

#Issue : Error running npm run dist for Bootstrap #Error Detail: 'npm-run-all' is not recognized as a valid command, program or batch file. Recently installed Node.js and chocolatey. Verified everything added to the system path. Attempting to ex ...

Multer throws an error when uploading files due to an unexpected field issue

Hello, I am currently working on creating a file upload API using React and Express. To achieve this, I decided to use Muster. However, when I send an Axis request from the client, I encounter an error from the server. Error: MulterError: Unexpected fie ...

I am looking for a way to convert the date format from "yyyy-MM-dd" to "dd-MM-yyyy" in NestJs

I need help with changing the date format from "yyyy-MM-dd" to "dd-MM-yyyy". Currently, my entity code looks like this: @IsOptional() @ApiProperty({ example: '1999-12-12', nullable: true }) @Column({ type: 'date', nullable: true }) birthDate?: Date ...

Execute npm and node using ansible

I am facing a challenge with the script execution on a machine that has zsh installed. Here is what I have set up: Software Installed # Install NVM sudo curl https://raw.githubusercontent.com/creationix/nvm/v0.31.0/install.sh | bash ## Reload shell to st ...

Setting up event triggers once readline is activated

Reading a file line-by-line in NodeJS typically involves calling readline.createInterface, and then attaching event handlers for line and close. It's interesting how the reader seems to start on its own without any explicit trigger. How does it know ...

Guide on using ExpressJS and RethinkDb: Dealing with the error message "Cannot read property 'prototype' of undefined"

Just starting out with databases and JavaScript, I decided to dive into learning ExpressJS and RethinkDB using a tutorial provided by this link: https://github.com/rethinkdb/rethinkdb-example-nodejs-chat Following the instructions closely, I encountered ...

Encountering issues with connecting to the MongoDB server through Node.js

When working with MongoDB in Python, everything runs smoothly without any errors. However, when using Node.js, an error keeps popping up. Can someone please guide me on how to resolve this issue? jdcaovuwqxoqppwwqmjcawpwuaciwowjqwqhpaiwdoqi Below is the ...

Is there a way to modify the URL in a Node.js request using JavaScript?

Is there a way that I can modify the API 'keyword' parameter to show different results each time it is accessed? Specifically, I am looking to achieve this with the following endpoint: http://localhost:3009/api/get-products/?keywords=naruto. app.get( ...

Choosing the user object in Passport and Express: How to determine which user data will be included in the req object?

I am working on authentication using Passport Js in my Node Js / Express app. The issue arises when dealing with large user objects that are always included in the request object, resulting in a decrease in performance for these users due to the data sche ...

Error in binding the port during Heroku deployment with webpack

I am facing an issue while deploying my package.json with all the dependencies and a start script using webpack on Heroku. The error message I get is R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch. "scripts": { "star ...

"Encountering a Type Error in Express.js When Trying to Import Database Schema

Currently working on a small web app using the MEAN stack and going through the process of moving my schemas to a separate "models" directory. Everything runs smoothly when the schemas are within the same app.js file, but once I organize them into a modula ...

What is the process for invoking a microservice (constructed in express js) from an angular application that is currently communicating with a sails js backend?

I had initially developed an application with Angular frontend and Sails JS backend. However, I recently separated some of the backend functions into a micro-service using Express. Now, I am looking for guidance on how to call these functions from my mai ...

Tips on executing npm commands on Azure app service following a successful deployment via VSTS?

While I've successfully deployed from VSTS to Azure, I'm facing an issue with running npm after the deploy is complete. The current process involves running npm install for branch files, zipping them, copying to Azure, and deploying. However, I ...

Can you explain the distinction between mongoose.save() and passport-local-mongoose.register()?

Can you explain the distinction between using mongoose's .save() and passport-local-mongoose's .register() functions? Why is it that passport-local-mongoose's .register() function only requires a username and password? Wouldn't it be beneficial to also in ...

The module 'iap_verifier' could not be located

Setting up a new server using the following repository - https://github.com/surespot/web-server. I have successfully installed node.js, npm, CoffeScript, and all required dependencies. apt-get install nodejs npm npm install -g <a href="/cdn-cgi/l/email ...

How can the request object be obtained in a Node.js lambda function using Serverless Websockets?

Connecting my client application to the Websocket server using the URL: wss://xxxxxxx/xxxxx/xxxx?value=abcd The WebSocket server I'm working on needs to retrieve the value "abcd" that is passed by the client in the request URL. However, all I can find in ...

How can user input be captured in the terminal following the execution of npm start?

Imagine a basic program running in the background. Here is a simple simulation (index.js). process.stdin.resume(); console.log('just hanging...') If you run it with node index.js, nothing else will happen until you exit with ctrl+c. Even though ...

Don't forget to adjust shrinkwrap.json when a dependency is relocated to the devDependencies section

After mistakenly running npm i --save xxx and having my shrinkwrap.json updated correctly, I realized I actually wanted to use --saveDev. I began exploring solutions on how to revert this mistake. My initial thought was to run npm uninstall --save xxx, bu ...

Is there a method to display logs in Node JS without relying on process.stdout.write?

I am currently experimenting with piping two Node.js scripts together, and I have found that it works well when using the following method. How to pipe Node.js scripts together using Unix | pipe (on the command line)? For example: $ ./script1.js | ./scr ...

Effortlessly passing request values to context in ExpressJS

During the migration process from Django to Express, I am simplifying by passing `req.user0` and `req.isAuth` values into the view as variables through context. Here is an example: router.get('/', (req, res) => { res.render('index', { isAut ...

Tips for extracting JSON data from an API with identical names as values

I am working on a project to create a data search system using JSON. The JSON data is stored in a REST API, and the structure of the API is as follows: [ { "info": "cute but big animal", "type": "pig", ...

The value of req.files consistently shows as undefined

My issue is with req.files consistently returning undefined. Despite attempting connect-multiparty, body-parser, and express-fileupload, I can't seem to make it work with express-fileupload instead of multer. Can anyone help me troubleshoot this probl ...

Warning: The usage of `--global` and `--local` in the global configuration is no longer supported. Please utilize `--location=global` instead. Additionally, an error has occurred due to an

npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead. npm ERR! Unexpected token '.' Everything was working fine on my computer until npm/npx suddenly started throwing this error. The same error pops up every time I ...

Managing relationships within TypeORM's single table inheritance using a base class for targeting relations

In my application, I aim to provide users with notifications in the form of news items of various types. The relationship between User and NewsItem needs to be one-to-many, with NewsItem serving as a base class for different types of news items. Below is ...

Navigating the complexities of Async/Await: Exploring the challenges of Async/Await

Utilizing async/await, I aim to showcase the data obtained from a readable stream prior to displaying the corresponding message. Below is my code snippet: var stream = async function (){ var myStream = fs.createReadStream(__dirname+"/someText ...

Angular Error cli command Error: In order to proceed, please provide a command. To see a list of available commands, use '--help'

When I run any command with Angular CLI, I encounter an error. To resolve this issue, I attempted to uninstall and reinstall it by running the following commands: npm uninstall -g @angular/cli npm install -g @angular/cli However, the problem persists an ...

The website is functioning properly on port 8080, however, it is not working on the root directory

My website is functioning properly with the domain name test.in:8080, however it is not working on just test.in. Here is an excerpt from my nginx.conf file for reference: server { listen 80 default_server; listen [::]:80 defaul ...

Mongoose - embedded documents are stored as text data

Within my node application, I have a designation model that utilizes the following Schema: var DesignationSchema = new Schema({ _id : ObjectId, designation : String }); This DesignationSchema is then embedded within the users Schema. var UserSch ...

Express is utilizing HTML entities for formatting JSON data

We are encountering a problem with our NodeJS application which is based on express and body-parser. The issue arises when certain characters in the REST requests, sent in JSON format, get HTML/XML escaped unexpectedly. We suspect that something within eit ...

Is it possible to seamlessly transition an express app to meteor?

Currently working on migrating an app from node.js with express framework to meteor. Attempting to reverse engineer the process using a method similar to https://github.com/onmodulus/demeteorizer ...

The most common method for incorporating subdomains (such as the jp in jp.sweet-website.org) into nodejs applications

The current versions are Express 4.10.2 and Node 6.5.0 How can I create a subdomain for my website? I am looking to include a Japanese version of my site that will be accessible through http://jp.site-in-question.run in addition to the default English ...

Error: It is not possible to assign a value to the Request property of the Object since it only has a getter method

Encountering issues while attempting to deploy my Typescript Next.js application on Vercel. The build process fails despite functioning correctly and building without errors locally. Uncertain about the root cause of the error or how to resolve it. The f ...

Creating MySQL query results in Node.js manufacturing process

I am looking to format the MySQL result in Node.js in a specific way. The desired result format should look like this: [ { "m_idx" :1 , "contents" : { "m_name" : "a", ...

Error: The function client.db is not recognized in MongoDB Atlas

I am attempting to establish a connection to MongoDB Atlas in Node.js using the client "mongodb": "^3.5.5" by following the instructions provided in this particular guide. A successful connection message of console.log('connected to db') is displ ...

When using `npm publish`, any files located within the `node_modules

After developing an npm package, I included some modules in the node_modules directory to make them accessible as "modules". For instance, I have a module called my-module.js in node_modules which I require in my code using require('my-module'). Upon runni ...

Node.JS product creation triggers a Stripe outage

Attempting to create a product in stripe has been problematic for me. Every time I make the call with stripe.products.create(), it causes lag, and shortly after my server crashes due to 'JavaScript heap out of memory'. Here is my approach: impo ...

What are the best practices for adding images to mongoDB Atlas using multer?

I am working towards the goal of uploading images to MongoDB Atlas using Multer. Currently, I have an example set up with express-generator, which includes the following relevant files: app.js: // ... var app = express(); //Set up mongoose connection va ...

Passing Node.js MySQL query results to the next function within an async.waterfall workflow

In my node.js code using express, I have set up a route to request data from a mysql database. My goal is to pass the returned JSON in tabular form to another function to restructure it into a hierarchy type JSON. I have individually tested the script to ...

How can eslint be used to enforce a particular named export?

Is there a way to use eslint to make it mandatory for JavaScript/TypeScript files to have a named export of a specific name? For instance, in the src/pages folder, I want all files to necessitate an export named config: Example of incorrect usage src/page ...

Deployment replacement in Kubernetes encounters error

I've developed a NodeJS script to deploy review apps to Kubernetes for my GitLab repository, using the Kubernetes NodeJS client. Including abbreviated definitions of Kubernetes resources for thoroughness: const k8s = require('@kubernetes/client-node'); ...

How is it possible for TypeScript to enable the importing of dependencies that it ultimately cannot utilize during runtime?

Take a look at my sample project by following this link: https://github.com/DanKaplanSES/typescript-stub-examples/tree/JavaScript-import-invalid I have developed a file named main.ts: import uuid from "uuid"; console.log(uuid.v4()); While type ...

Error: 'require' function is not recognized in the latest JavaScript file

I am interested in using anime.js. To install this library, I need to follow these steps: $ npm install animejs --save const anime = require('animejs'); The code should be written in a js file named "anime.js" Here is the code for "anime.js": ...

AngularJS chatbox widget for interactive communication

Currently, I am in the process of developing the back-end for a web application utilizing angularJS. One of the key features is allowing users to communicate with each other through a pop-up chat box similar to those found in Gmail or Facebook. My goal is ...

The app.use function encountered an error stating "Cannot modify header information - headers already sent"

Within my app.js file, I have the following code snippet: app.use(function(req, res, next){ if(!req.user){ res.redirect('/login_'); } next(); }) Upon reviewing the above code, everything appears to be correct. In my route/index.js file, I have ...

Which is quicker: reading two files with fs.readFile or using fs.readFileSync?

During the 5:40 mark of this video, it is mentioned that the non-blocking version (using fs.readFile instead of fs.readFileSync) reads files in parallel, resulting in faster execution. But how could this be possible if Node.js operates on a single thread? ...

What is the best way to retrieve data from an entity with Prisma where the number of its children exceeds a certain threshold?

I am working on a project where I have an entity called Author that can have multiple Books associated with it. My goal is to retrieve all Authors who have more than 5 books in my database. The application is built using Prisma in conjunction with Next.js ...

Tips for ensuring that req.query only accepts date formats in the format yyyy-mm-dd

Can someone help me figure out how to restrict my req.query so that it only accepts dates in the format YYYY-MM-DD? Right now, my code is allowing random numbers like "123456" to be entered into the query. ...

NodeJs - Issue: Headers cannot be changed once they are sent & TypeError: req.next is undefined

My goal is to retrieve data from a MySQL database by calling methods to insert and read information. The reason I am doing this is because node.js operates asynchronously. Here is my code: exports.list = function(req, res){ var moduleRows; req.getCo ...

Transforming an object into an interface in TypeScript

Recently, I have started learning Typescript and am currently working on a project where I am building a REST API. In this project, I have defined a specific model for my request payload. However, even after typecasting, the type of 'resObj' rem ...

Fetching JSON data from a Node.js server and displaying it in an Angular 6 application

Here is the code snippet from my app.js: app.get('/post', (req,res) =>{ let data = [{ userId: 10, id: 98, title: 'laboriosam dolor voluptates', body: 'doloremque ex facilis sit sint culpa{ userId: 10' }, { id: 99, ti ...

Attempting to retrieve the current time using JavaSscript

const currentTime = new Date(); const hours = now.getHours(); Console.log(hours); This block of code is returning an error message... Uncaught ReferenceError: now is not defined Please note that this snippet is written in JavaScript. I attempted to us ...

Encountering a DiscordAPIError[10062] when attempting to retrieve user points from the database due to an unknown interaction

content: "Congratulations, you have been successfully verified!", ephemeral: true, }); } } else if (interaction.customId === "giverole") { const userPoints = await findUser(interaction.member ...

Error encountered during Stenciljs project setup

I am attempting to start a fresh stenciljs project by using the command npm init stencil Upon executing the above command, I encounter this error https://i.stack.imgur.com/L7ke4.png Could someone kindly assist me in identifying what is causing the issue. ...

Acquiring an icon of a program using its handle

I am looking for a way to extract a program's icon from its handle, which I acquired using User32.dll with EnumWindow/FindWindow. While I am aware of ExtractAssociatedIcon, it seems to work from a file instead of a handle. My question is how can I con ...

Installation of npm failed due to error codes E404 or ENOENT

My current node version is 8.9.1; NPM version I am using is 5.5.1; Whenever I attempt to install modules using NPM, I encounter errors such as 'code E404' or 'code ENOENT'; I have tried installing various modules, including 'tld ...

npm socket.io installation failed due to node version being less than 0.10.0

Having trouble installing socket.io on my BeagleBone Black because my system is using Node v0.8.22, but the required version for installation is above 0.10.0. Unfortunately, I am unable to upgrade my Node. /usr/bin/ntpdate -b -s -u pool.ntp.org cd /var/li ...

Is it possible to access an HTML element using NodeJS without relying on external libraries?

My current challenge involves accessing and changing the innerHTML of an HTML element. My application must connect to a database and perform CRUD operations, which worked successfully when connected to the database via cmd and localhost 3000. However, I en ...

I am looking for a solution on how to validate a token issued by Auth0 in a nodejs backend using jwt, but I keep

My React frontend uses Auth0 for user authentication. Once a user is logged in, I retrieve the token using getAccessTokenSilently() and send it to the backend like this: const { user, isAuthenticated, getAccessTokenSilently } = useAuth0() useEffect(() =&g ...

What is the process for exporting/importing a variable in Node.js?

What is the correct way to export/import a variable in Node.js? I attempted to use export and import methods, but I received an error message stating that it should be a module. After changing the type to module in the JSON file, it then told me that requ ...

Deleting a variable parameter's length in Firebase Cloud Function

Here is a code snippet that I am working with: //index.js export const deletePicture = functions.region("europe-west1").database .ref("galleries/{galleryId}/{pictureId}") .onDelete(pictures.deletePicture) //pictures.js export const deletePicture = (s ...

Why does this vow continue to linger unresolved?

I've been experimenting with a code that involves adding promises to a queue for processing in a non-blocking manner. One code snippet behaves as anticipated while the other doesn't, leaving me puzzled. Problematic Code: const axios = require('axios'); co ...

"An issue has been observed with libxmljs compatibility on Node version 12.19.0 specifically on

I am currently using Node version 12.19.0 and NPM version 6.14.8 on a Windows system. I recently attempted to install the latest version, which is 0.19.7, and encountered no installation issues. E:SSService>npm install libxmljs > <a href="/cdn ...

What causes the discrepancy in size between development mode bundles created with lodash and lodash-es?

webpack.config.js const path = require('path'); const HtmlWebpackPlugin = require('html-webpack-plugin'); module.exports = { mode: 'production', entry: { app: './src/index.js' }, plugins: [ new HtmlWebpackPlugin({ title: 'p ...

Experience the power of SSR Nuxt.js with a seamlessly integrated REST API backend

Currently, I am working on developing a SSR Nuxt.js application that integrates with a REST API server. In order to achieve this, I have included my endpoint /api into the Nuxt server.js code as shown below: const express = require('express') c ...