Questions tagged [node-js]

100249 questions
1

votes
1

answer
61

Views

How the sender can see its own messages too with socket.io?

I'm using socket.io and I want to send a message to a specific user by its socket.id and that the sender will see its own message too. I get the socket.id and sending the message by: socket.to(msg.id).emit('chat message', msg.message); which msg.id is the socket.id of the recipient. I found out tha...
zb22
1

votes
0

answer
88

Views

How do I get rid of BSON objects after a mapReduce?

I'm a complete beginner to map-reduce and relatively new with MongoDB. I am trying to perform a map-reduce on a collection (by the name Customers). My map function: var map = function() { emit(this.nationality, {edad: this.age, telefono: this.phone_number}); }; My reduce function: var reduce = funct...
1

votes
0

answer
1.4k

Views

nodejs websockets subscribe to multiple channels

The end goal is for my nodejs program to subscribe to multiple channels supplying real-time financial information and processing the streaming data. In python it is possible to subscribe to multiple channels using the functools/partial and websocket. This allows one python program to subscribe to mu...
GerM
1

votes
0

answer
609

Views

How do I solve these errors with npm install and sudo npm install -g harp?

I was trying to install Node.js, Grunt and Harp so I downloaded Node.js and then I wrote in the terminal this (note: I also had Homebrew): node -v npm update -g npm npm install -g grunt-cli After that I installed Bootstrap files and I wrote (always from the terminal) I wrote: npm install the termina...
Pier
1

votes
0

answer
512

Views

I get a 503 response status whenever I try to make a POST request from my client

I recently created a server and deployed it to Heroku. It works fine in Postman and when testing out basic GET requests. But whenever I try to make POST request to it via Axios in my client, I am met with this error. In my back-end server, I enabled cors so that it could make cross-domain requests....
MountainSlayer
1

votes
0

answer
731

Views

Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded - hex is different

I have a legacy classic asp application, that allows us to upload pdf files. The file is saved as hex into a MS SQL DB into an image column. Here is a snip of the data in the column: 0x4A564245526930784C6A634E436957317462573144516F784944416762324A7144516F... We are now working on a rework of the app...
user8408326
1

votes
1

answer
92

Views

Divide gulp-file into several files

I want to divide one big gulp-file into several files. Some of this files is supposed to contain gulp-tasks, others – raw functions, third files – both. How can I do it? I've tried to create directory with a few files, some like that: gulpfile.js gulp/ ├── css_tasks.js └── js_tasks.j...
1

votes
0

answer
219

Views

I can't reinstall or update Electron package

Microsoft Windows [Version 10.0.16299.125] (c) 2017 Microsoft Corporation. All rights reserved. D:\nodejs projects\New>npm update electron [email protected] postinstall D:\nodejs projects\New\node_modules\electron node install.js I have this error when I start the project: Error: Electron failed to ins...
Zoubair Daddow
0

votes
1

answer
3k

Views

TypeError: path must be a string or Buffer MEAN stack

I am using Angular 5 on front-end, Node on back-end and Mongo as the database. Now I am trying to save an image to the database but constantly getting this error. I can't figure out if I'm making mistake on front or back because this is my first time working with files. I did my research but it poin...
JKshort
1

votes
0

answer
369

Views

Is it possible to use Jasmine without Karma for testing Angular/Node based Nw.js apps?

I've read ton's of tutorials, but I must admit that this testing stuff is still very confusing to me. I have a Nw.js app which (of course) uses NodeJS and also Angular. I've installed the Jasmine test framework globally via npm and wrote an example test which starts with the following lines, and pla...
Bernd
1

votes
1

answer
1.4k

Views

How to properly use sub query in sequelize?

...... ..... return myDb.myTable.rollgroup.findAll({ attributes : ['ID','GROUPNAME'], where : { id : { $notIn: ? //// how to use subQuery here } } }).then((getResult) => { return getResult; }) ....... ....... My raw Query Like this: select mg.ID,mg.GROUPNAME from mygroup mg where mg.ID not in (selec...
mani
1

votes
1

answer
1.1k

Views

webpack build error TypeError: Converting circular structure to JSON

I'm facing an error in building and running dev server with Webpack. I use Vue.js and used vue-cli for generating a project. For testing, I'm using Jest and npm test runs with no problems. If I run npm run build I get this error output: ERROR in TypeError: Converting circular structure to JSON -...
Mikeee
1

votes
1

answer
327

Views

How Can I change Image type with NodeJS?

I need to change my Image type after Uploading. I have tried with image_magick but failed.What is the best way to change a image type.
mad max
1

votes
0

answer
78

Views

Define a custom slot type that is no list

I am trying to code a youtube-subscriber-amount skill for Alexa. If you ask 'Alexa, ask subscribercounter for the subscribercount of {Channel}' I want to return {Channel}s subscribercount using youtube data api v3. My Problem is that I'm not sure how to create a slot in Alexa's interaction model, al...
BlockLab
1

votes
1

answer
130

Views

Node.js timing w/ activedirectory package

I'm quite a noob with Node but found that the activedirectory package is far better than any alternative Python module for extracting recursive group members across an AD forest so figured, right tool for the job. I've done loads with JS before but obviously this is a different kettle of fish. Basic...
Allan M
1

votes
1

answer
36

Views

node redis - id generation race condition

Multiple processes have access to my redis store. When adding a new user hash, I do the following steps: incr userId set user:[the incremented userId] ... How can I bundle these steps into a transaction? const client = require('redis').createClient(); client.on('connect', () => { const multi = clien...
nagy.zsolt.hun
1

votes
2

answer
386

Views

different between callback and promise in node.js

my code : const readline = require('readline'); function scan(callback) { const rl = readline.createInterface({ input: process.stdin, output: process.stdout, prompt: '> ', }); rl.prompt(); rl.on('line', (line) => { callback(line); rl.close(); }).on('close', () => { process.exit(0); }); } scan(data...
Rife
1

votes
2

answer
73

Views

Google chart not draw

I have a one question. google chart not draw. Here is my code google.load('visualization', '1', {packages:['corechart']}); google.setOnLoadCallback(drawChart); function drawChart() { var jsonData = $.ajax({ url: '/temhum', dataType:'json', }).done(function (jsonData) { var data = new google.visuali...
전준휘
1

votes
1

answer
90

Views

ts-node error: Could not find a compatible `parseConfigFile` function

I just install the ts-node with npm install -g ts-node but I can't execute the REPL, it gives me this error: /usr/lib/node_modules/ts-node/src/index.ts:478 throw new TypeError('Could not find a compatible `parseConfigFile` function') ^ TypeError: Could not find a compatible `parseConfigFile` functi...
geckos
1

votes
0

answer
24

Views

Why does mongo still throw error when I am handling error with if statement

I am deliberately trying to create duplicate key error by following code. let repoTemplate = new RepoTemplate({ name: templateName, //mongoose schema - unique creator: req.user.username, sheetsInfo: { calc: calcObj, result: resultsObj, data: dataObj, reference: referecneObj } }); repoTemplate....
forJ
1

votes
0

answer
314

Views

Node.JS: fs.readFile not working on Ubuntu

I'm trying to read some xml files, and when I test the code in my computer (OS X) it's working really good, without problems, but when I test the code in a Ubuntu 16 Server in DigitalOcean, I get nothing... I'm using fs.watch() and yes, it has nothing to be with the route because the program knows t...
CanKer DiAlike
1

votes
0

answer
51

Views

import python statements not working when called from JS

I'm unable to run my Python code from node.js. The following is the Python code I'd like to run: from preprocessor import pad_vec_sequences, labels from keras.models import load_model import spacy from preprocessor import nlp import numpy as np import sys from dependency_tree import to_nltk_tree , t...
Nirvan Anjirbag
1

votes
1

answer
326

Views

How to kill a npm child process

I've a package.json on which I define a debug script. This script launches a node app. The whole npm script is being launched by a test, and this last one must kill the debug script once the test ends. So when I spawn npm run debug and I kill it, the node process isn't killed. I've tried to either...
Matías Fidemraizer
1

votes
0

answer
25

Views

MarkLogic node.js: stream end event doesn't fire for certain collections

I have a query using MarkLogic node.js that basically boils down to something like this: db.documents.query(qb.where(qb.collection('test'))).stream() .on('data', function(row) { console.log('Stream on data'); }) .on('end', function() { console.log('Stream on end'); }) .on('error', function(error) {...
Roy Tang
1

votes
0

answer
109

Views

How to make PM2 reload a node_modules sub-folder

I have a NodeJS app my-project, that has a module my-module as a dependency. Currently, whenever I make changes to my-module, I have to ctrl + C to quit PM2, and type pm2 start ... to start up my-project again. This is my pm2 config file. As you can see, watch is already enabled; However, unless I...
Christopher Francisco
1

votes
0

answer
28

Views

Return to the original page ElectronJs

I've been looking for a solution to my problem for a while and I can not find it, so I decided to publish it to see if you can help me. My code is the following: exports.changePage = (link) => { mainWindow.loadURL(link + '/game') } exports.defaultPage = () => { mainWindow.loadURL(url.format({ pathna...
Ćarlos Omar
1

votes
1

answer
187

Views

nodejs async waterfall use function from external required javascript file

I am fairly new to nodejs, and to keep my code brief, was hoping I could use functions from a .js file I include in my async waterfall list of functions. I have tried to include one function, and am getting either a 'TypeError: callback is not a function' exception or 'Cannot read property 'Symbol(...
Ron
1

votes
1

answer
112

Views

Can't require renderer in http protocol in electron

Can anyone explain me why this code is not working? I tried to require the renderer in file protocol (without express static server) and it was fine, but when i do this with http protocol i got Uncaught Error: Cannot find module './renderer' ! Is there any way to require custom modules in http? Than...
Sadra Samadi
1

votes
0

answer
32

Views

WebStorm IDE not suggesting properly

I am using WebStorm IDE with their suggested types-def and it's working on most of the cases. The problem is that when I use: const {Project} = require('../db/models/projects') instead of: const Project = require('../db/models/projects').Project it does not suggest any of the mongoose methods for th...
jmrueda
1

votes
0

answer
183

Views

How can i generate hmacsha512 in Node Js

var crypto = require('crypto'); var output = encrypt(key,str); function encrypt(key, str){ var hmac = crypto.createHmac('sha512', key); var signed = hmac.update(new Buffer(str, 'utf-8')).digest('base64'); return signed } Here i am not getting proper output as same ouput in Java.byte[]...
Nani Kn
1

votes
0

answer
140

Views

How to handle async upload file with NodeJS?

I use Multer to manage file upload. I must verify with JWT (this.verify) to confirm this post. If it is success then my file was uploaded. Because my code is asynchronous, I cannot call this.configUpload(). This is the router: const mailer = require('../../libraries/mailer_lib'); router.post('/',mai...
Faustrata1
1

votes
0

answer
67

Views

Nano.auth fails when require_valid_user = true

Below is my sample code referring to this doc: https://github.com/dscape/nano#using-cookie-authentication var nano = require('nano')('http://localhost:5984') const username = 'test' const userpass = '123123' const callback = console.log // this would normally be some callback const cookies = {} // s...
komorebi
1

votes
1

answer
175

Views

How to control console text color when running npm test?

When I run tests (using Jest if that matters) by running npm test in a Node console, my console text becomes muted green, which is hard for me to read. I know that I can reset it by running color afterward, but what I want to do is be able to control the color so that the output text for each of my...
delliottg
1

votes
0

answer
499

Views

How to remove all/single event listners in socket.io

I am using socket.io for realtime functionality in my app with hapijs. When I am trying to add a listner on server side in a hapijs route and if I reload the same route/page 10 times or more then it starts showing me an error (node:9004) MaxListenersExceededWarning: Possible EventEmitter memory leak...
Dimpal Singh
1

votes
1

answer
233

Views

aws-iot device and jobs looses connections in the same process

I have a connection to using the device sdk const device = awsIot.device(config.DeviceOptions); I want also to use the new jobs sdk const jobs = awsIot.jobs(config.DeviceOptions); then i get connect offline connection lost - will attempt reconnection in 1 seconds... close reconnect how is it possib...
Roninio
1

votes
1

answer
194

Views

Wait for save before continuing with the function

I have a loop which loops through an array of users, this loop is asynchronous, what I want to do is for every user create a new document and save it and wait for this to save and then move on to the next user. I am able to handle when to move on to the next user, so my problem is while saving the n...
Muhand Jumah
1

votes
2

answer
135

Views

Mongoose populate where

I have two models - M1 and M2. In M1 I have an array of M2 objects. I'm trying to create a query that will grab a bunch of M1 models but ONLY if a certain field in M2 matches the criteria I set. I've setup the models correctly (so M1 has an array of Schema.Types.ObjectId for M2). Ideally I'd want t...
user1157885
1

votes
0

answer
94

Views

Converting an Angular 4 Web app to Angular Universal

I currently have a web app that is running on Angular 4 and express-node.js in the backend. Due to problems with SEO, I want to migrate to Universal. But I would like to do so with minimal changes in my codebase, especially how my server.js is currently handled. In all guides I have seen and even in...
Sayak Mukhopadhyay
1

votes
0

answer
42

Views

webpack solve require arguments before build (constexpr)

I'm working on a RESTful API express.js server. what I expect is something like A node Express router middleware for RESTful API base on certain folder path. but this package using dynamic require which loads modules on runtime with an expression. this cause webpack throw an error: Critical dependen...
Zazck
1

votes
0

answer
31

Views

How can file writes with NodeJS on Docker be inconsistent?

A while back I've created some feed fetching & processing scripts with NodeJS for an application I'm working on. I've been running this script on my local machine (OSX) manually for a while and momentarily I'm working on having a job do this. I figured I'd go with a Docker droplet ($5/mo) on Digital...
nicoes

View additional questions