Node.js

244

Solutions

361

Contributors

Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient. Node.js' package ecosystem, npm, is the largest ecosystem of open source libraries in the world.

Share tech news, updates, or what's on your mind.

Sign up to Post

I am using Nodejs in an electron project.

This question is about Nodejs and the request module

My question is, how do I post a file to a url using this module?
0
I tried to npm uninstall -g is not working.

First I had tried npm ls -g --depth=0 it produced the following results

  /usr/local/lib
  ├── UNMET PEER DEPENDENCY @babel/core@7.0.0-beta.4
  ├── @babel/node@7.0.0-beta.44
  ├── aws-cli@0.0.2
  ├── babel-core@6.26.0
  ├── babel-loader@7.1.4
  ├── babel-plugin-transform-decorators-legacy@1.3.4
  ├── babel-plugin-transform-object-rest-spread@6.26.0
  ├── babel-plugin-transform-optional-chaining@7.0.0-beta.3
  ├── babel-preset-react@6.24.1
  ├── babel-preset-stage-3@6.24.1
  ├── babel-register@7.0.0-beta.3
  ├── coffeescript@2.2.4
  ├── graceful-fs@4.1.11
  ├── minimatch@3.0.4
  ├── n@2.1.8
  ├── npm@5.8.0
  ├── ntdl@1.0.2
  ├── pdf-compress@1.0.0 -> /home/ubuntu/workarea/sourcecode/pdf-optimise
  ├── virtualenv@0.3.1
  ├── UNMET PEER DEPENDENCY webpack@2 || 3 || 4
  └── yarn@1.5.1

  npm ERR! peer dep missing: @babel/core@7.0.0-beta.44, required by
  @babel/node@7.0.0-beta.44
  npm ERR! peer dep missing: webpack@2 || 3 || 4, required by babel-
  loader@7.1.4
  npm ERR! peer dep missing: @babel/core@7.0.0-beta.44, required by
  @babel/register@7.0.0-beta.44
  npm ERR! peer dep missing: webpack@>=0.9 <2 || ^2.1.0-beta || ^2.2.0,
  required by worker-loader@0.8.1
  }
Then I had tried uninstalling it didn't succeeded

  root@ip-10-252-14-11:/home/ubuntu/workarea/sourcecode/ntdl# sudo npm
  uninstall -g @babel/node@7.0.0-beta.44
  up to date in 0.063s

  …
0
Hi Experts,

I get the following error when I run babel-node

Please see the error below


root@ip-10-252-14-11:/home/ubuntu/workarea/sourcecode/ntdl# babel-node node/react-render.jsx

/usr/local/lib/node_modules/@babel/core/node_modules/@babel/template/lib/builder.js:86
      throw err;
      ^

Error: Unknown substitution "BODY" given
    at /usr/local/lib/node_modules/@babel/core/node_modules/@babel/template/lib/populate.js:22:15
    at Array.forEach (<anonymous>)
    at populatePlaceholders (/usr/local/lib/node_modules/@babel/core/node_modules/@babel/template/lib/populate.js:20:31)
    at /usr/local/lib/node_modules/@babel/core/node_modules/@babel/template/lib/string.js:20:51
    at /usr/local/lib/node_modules/@babel/core/node_modules/@babel/template/lib/builder.js:83:14
    at spec (/home/ubuntu/workarea/sourcecode/ntdl/node_modules/babel-plugin-transform-es2015-for-of/lib/index.js:159:20)
    at PluginPass.ForOfStatement (/home/ubuntu/workarea/sourcecode/ntdl/node_modules/babel-plugin-transform-es2015-for-of/lib/index.js:72:21)
    at newFn (/usr/local/lib/node_modules/@babel/core/node_modules/@babel/traverse/lib/visitors.js:223:21)
    at NodePath._call (/usr/local/lib/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:64:19)
    at NodePath.call (/usr/local/lib/node_modules/@babel/core/node_modules/@babel/traverse/lib/path/context.js:38:17)
    =============
    at exports.default …
0
I want to get the DOM code from a web page in a given url.

Right now I have been trying jQuery:

$.get( "http://localhost/test.html", function( data ) {
  console.log(data);
});

Open in new window


But it's just giving me the actual source code and not the code given after the page is executed in the browser.

There are some variable values that are only displayed when in the DOM and not shown in the source code so I need to get the code in the DOM.

How can I do this?
0
I am using this code for submitting a file using jQuery:

$(document).ready(function() {
    $('form').submit( function() {
        $.ajax({
            type: 'post',
            url: 'http://localhost/test/upload.html',
            data:{file},
            success: function (data) {
                alert("done")
            }
        })
    })
})

Open in new window


The problem I am facing is that I am not getting the messages (either successful or error messages) given by the page.

How can I change this code so that it returns error or successful messages given by the upload.html page?
0
Hi,
I have code in angular i want to modify it improve it is it possible to find some freelancer to first look at that code and tell me the cost to modify it.


Thanks
1
I am trying to write some code where I have the ParentPage.html and ChildPage.html

On ChildPage.html I have a form:

<form>
  First name:<br>
  <input type="text" name="firstname" value="">
  <br>
  Name:<br>
 
  <input type="submit" value="Submit">
</form> 

Open in new window



Both pages are on my localhost.

I need to add some code on ParentPage.html that with hit the submit button on ChildPage.html

Can this be done using NodeJs? If so how?
0
Hello.

I am learning Node JS with Visual Studio Code from Microsoft. Here is the Javascript file:

«test3.js»:

const express = require('express')
const app = express()
const port = 9999

app.get('/', function (request, response) {
  response.send('Allo de Express!')
})

app.listen(port, function (err) {
  if (err) {
    return console.log('Oups! Une erreur est survenue', err)
  }

  console.log(`À l'écoute sur le port ${port}`)
})

I had installed «express» with this command:

PS C:\Users\jean\Documents> npm -g install express
+ express@4.16.3
added 1 package, updated 2 packages and moved 2 packages in 11.24s

PS C:\Users\jean\Documents> cd node_modules
PS C:\Users\jean\Documents\node_modules> ls


    Répertoire : C:\Users\jean\Documents\node_modules


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       29/03/2018     14:59                bytes

There no directory for the module «express». Where is it?

When I execute the Javascript file, I get an error:

PS C:\Users\jean\Documents> node test3.js
module.js:549
    throw err;
    ^
Error: Cannot find module 'express'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (C:\Users\jean\Documents\test3.js:1:79)
    at Module._compile …
0
I'm having trouble wrapping my head around a clients DAG config.  They have a 5 Node DAG, 3 MBX servers in Primary Site and 2 MBX in Secondary site, no FSW.  Cluster Quorum is Node Majority.  When Primary site goes down, DAG copied in Secondary site goes Offline as Quorum is lost. What can I configure to have the DAG Copies in the Secondary site to stay operational?  Even if I put a FSW in the Secondary Site, the Cluster will ignore is because it's a 5 node cluster.
0
Hi Experts,

      I had tried installing Canvas with NPM.  Installation is not succeeding.  I get the following error

c:\...\node_modules\canvas\src\Canvas.h(19): fatal error C1083: Cannot open include  file: 'cairo.h': No such file or directory (compiling source file ..\src\CanvasGradient.cc)
 [C:\...\pdf-optimise\node_modules\canvas\build\canvas.vcxproj]

I had followed the steps mention at this url  https://github.com/benjamind/delarre.docpad/blob/master/src/documents/posts/installing-node-canvas-for-windows.html.md

Please help me in resolving this. issue

With Many Thanks,

Bharath AK
0
We have a 2 node Server 2012 R2 cluster with a number of file server clustered roles installed and balanced across the nodes

On one of these network drives if anyone tries to open an office file that is in use then we get a message saying the file cannot be opened.  Nothing further.  No option to open read only or anything like that.  Just bam. Can't open.

We have failed the role over to the other node, rebooted the node... nothing.

The other roles are fine.  Office files can be opened as read only if someone else has it open.

Any help would be greatly appreciated.
0
what happens at every step of our network model, when a node on one network establishes a TCP connection with a node on another network. You can assume that the two networks are both connected to the same router...... how it works?
0
I'm interested to know what languages are the best to learn or learn more of.  
I have a pretty good understanding of PHP.  I also know some Javascript and am taking a course through Udemy to further understand it.  Right now I have time to learn/study a little.  What would be the best things to know and understand? Node, API, advanced CSS???  What are your thoughts?
0
Hi Experts,

       I am working on an web application (wagtail cms) like django-cms, which is in aws ubuntu.  Its backend is postgres, with elastic search few modules reactjs and nodejs.
The application is deployed in docker containers.  uwsgi is the upstream server for nginx.

      I get lots of errors with npm build, i am not able to run the application.  sometimes ports are not accessible. postgres is using 5432, elasticsearch is 9200. react is rendering on 9009. I get lots of dependencies error.    At what situation I have to use dockers?  sometimes I get errors in nginx configuration. could please tell what is good practice for npm build, run deploy.  

    What is the best way to architect the development and test environment?

    Will I be able access the postgresql, elastic search and nginx in linux ubuntu on aws with cms source code and contents on windows local pc?   or having the copy of postgresql, elastic search, cms contents and nginx all on a windows pc as development environment environment.   Elastic search has huge data.  and how to deploy the application on dockers in linux environment.

    What is the best way to have a development environment?  what is best test environment

   could you please tell me on how elastic search data is stored on postgres and what is network host setting in elastic search how it accessed from outside application.

    Could you please throw light on how to create development and test environment.

with …
0
I am having an Angular build error.  This is the error I get.

ERROR in Error during template compile of 'AppModule'
  Function expressions are not supported in decorators in 'ɵ0'
    'ɵ0' contains the error at app\app.module.ts(35,23)
      Consider changing the function expression into an exported function.


Here is my app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { FormioAppConfig } from 'angular-formio';
import { FormioAuthService, FormioAuthConfig } from 'angular-formio/auth';
import { AuthConfig, AppConfig } from '../config';
import { AuthModule } from './auth/auth.module';

import { AppComponent } from './app.component';
import { HomeComponent } from './home/home.component';
import { HeaderComponent } from './header/header.component';
import { ApplicationModule } from './application/application.module';


@NgModule({
  declarations: [
    AppComponent,
    HomeComponent,
    HeaderComponent
  ],
  imports: [
    BrowserModule,
    RouterModule.forRoot([
      {
        path: '',
        redirectTo: '/home',
        pathMatch: 'full'
      },
      {
        path: 'home',
        component: HomeComponent
      },
      {
        path: 'auth',
        loadChildren: () => AuthModule
      },
      {
        path: 'application',
        loadChildren: () => ApplicationModule
      }
    ])
  ],
  providers: [
    FormioAuthService,

Open in new window

0
How can I remove an xml node from an XmlDocument object in c#?  For example, I want to remove <LastName> tag.....


Input:
<DataSet>
	<Person>
		<FirstName>Bob</FirstName>
		<LastName>Smith</LastName>
	</Person>
	<Person>
		<FirstName>Gina</FirstName>
		<LastName>Davis</LastName>
	</Person>
</DataSet>

Open in new window


Desired Result:

<DataSet>
	<Person>
		<FirstName>Bob</FirstName>
	</Person>
	<Person>
		<FirstName>Gina</FirstName>
	</Person>
</DataSet>

Open in new window



I'm using .NET Framework 3.5
0
I am using xml. query on the following xml

This node is the child of /PCRDATA/Activity
<Procedures>
      <Procedure>
        <EnteredBy ID="586807">XXXXXXXXXX</EnteredBy>
        <MedicationDosage>100</MedicationDosage>
        <MedicationDosageUnit ID="2835">MG</MedicationDosageUnit>
        <MedicationName ID="92">Ketamine</MedicationName>
        <MedicationRoute ID="2">IV - Push</MedicationRoute>
        <Procedure ID="Medication">Medication</Procedure>
        <ProcedureResponse ID="2">Unchanged</ProcedureResponse>
        <Comments>Ketamine, 100 MG via IV - Push given by xxxxxxxxxxxxxxxxxxxxxx). Pt. Response: Unchanged. </Comments>
        <ConsultEventID>xxxxxxxx</ConsultEventID>
        <EventID>2xxxxxxx</EventID>
        <ProcedureAuthorization>XXXXXXXXXX</ProcedureAuthorization>
        <ProcedureCrew>XXXXXXXXX</ProcedureCrew>
        <ProcedureDate>2018-01-17T19:53:00</ProcedureDate>
      </Procedure>

Open in new window


my query is as follows

value of @MedicationNameID1="92"


exec( 'declare @xml xml 
set @xml=(
  SELECT *
  FROM OPENROWSET(BULK'+ ''''+@FILENAME+''''+', SINGLE_BLOB) AS data
)
select 
@xml.query(''/PCRDATA/General/Outcome[@ID="'+@Disposition+'"]'').value(''.'', ''varchar(50)'') as DispDesc,
@xml.query(''/PCRDATA/General/DispatchedAs[@ID="'+@Nature+'"]'').value(''.'', ''varchar(50)'') as NatureDesc ,
@xml.query(''/PCRDATA/General/MedicalCategory[@ID="'+@MedCat+'"]'').value(''.'', ''varchar(50)'') as MedCatDesc,
@xml.query(''/PCRDATA/Actvity/Procedures/Procedure[1]/MedicationName[@ID="'+@MedicationNameID1+'"]'').value(''.'', ''varchar(50)'') as MedicationName1
' )

Open in new window


The value of MedicationName1 is blank.  I am expecting ketamine

Can someone point me in the right direction,  I am baffled.

Thank you
0
Hello. I am working on a node application.  I'm trying to use Passport for the log in.   I found an example online of what I want to do.  However I cannot get it to work.  I am running into an issue with my routes.  I get a compiler error that I have not seen before.  I tried to attached the project to this question, but it won't accept zip files so I will just attach my index.js and AuthController.js.  This is the error I get on index.js when it tries to do my first route.
 
var auth = require("../controllers/AuthController.js");

// restrict index for logged in user only
router.get('/', auth.home);

Open in new window

I get this error:  
index.js:349
throw new mongoose.Error.OverwriteModelError(name);
OverwriteModelError: Cannot overwrite `User` model once compiled.
at MongooseError.OverwriteModelError (C:\Users\ernest\Documents\coding bootcamp\code\Passport MongoDB\node-passport-auth\node_modules\mongoose\lib\error\overwriteModel.js:18:11)
    at Mongoose.model (C:\Users\ernest\Documents\coding bootcamp\code\Passport MongoDB\node-passport-auth\node_modules\mongoose\lib\index.js:349:13)
    at Object.<anonymous> (C:\Users\ernest\Documents\coding bootcamp\code\Passport MongoDB\node-passport-auth\models\user.js:12:27)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require …
0
How do we have a completely clean DEV environment to write an application in Node / Angular / Bootstrap / ...? I am having trouble with CLI's and updates each time. Does anyone have a real Best Practice? I would like to take an environment that I have been hacking around in and clean it up, ready for a new project easily.  Ideally, I would love to see a script to run that will clean it all up in one shot.
0
I would like to have a list of all backup / archive of a node with its size.
I have a 30-day retention, I should have a list with the last 30 backup / archive done and their size
0
We have 2 servers in a DAG and the network to the passive mode is down and I need to stop the dag replication from the active node to the passive but it wont allow me since the network to the passive node is down.
How can I stop the active server from trying to replicate to the passive node until the network to it is back on line?
0
How  can  I   run  NPM  commands behind a company  corporate proxy server?I tried to google online with no  success.
npm config set proxy http://xxx.cc.zz:8080
npm config set https-proxy http://xxx.cc.zz:8080
0
I've created a custom API for internal use and have query strings used to find specific assets - http://localhost:3000/api/asset?ipaddress=10.1.1.100 ... returns 1 device

What I would like to do is return results for all devices with the ip address that contains the substring in the query string - http://localhost:3000/api/asset?ipaddress=10.1.1 ... returns all devices within this subnet. Right now, this returns 0 devices.

Here's the structure of my router(s) -

router.get('/', verifyToken, function (req, res) {
    const query = {};

    if(req.query.clientcode)
        query.clientcode = req.query.clientcode;
    if(req.query.assetkey)
        query.assetkey = req.query.assetkey;
    if(req.query.name)
        query.name = req.query.name;
    if(req.query.siteid)
        query.siteid = req.query.siteid;
    if(req.query.ipaddress)
        query.ipaddress = req.query.ipaddress;

    asset.find(query,function(err, results) {
        return res.json(results);
      });
});

Open in new window

0
I found a health alert on our small S2D cluster saying there was not enough reserve capacity on the Cluster.  We have a two node storage spaces direct cluster with 4 1.6TB SSD's per server for a total of  about 11gigs total when I set up the cluster for mirrored pool there was only about 6gig usable which I split between the two servers I have two 2.7gig CSV's one has 915GB free the other has 1.95TB free. Does anyone know what I am missing here?

S2D1.JPGS2D2.JPGS2D3.JPG
S2D4.JPGS2D5.JPG
0
Hi

can someone know how to configure DAG on 3 exchange server that work on node majority method ?
the configuration look very simple but is`t request from me  to enter witness server   and  i know that in node majority method
the witness server is not necessary .
there is any way to bypass this request and create the DAG without witness server ?
and if i create it with witness server on node majority method  which data will be save/create  on the witness server
and were i should create the witness  is this situation?
0

Node.js

244

Solutions

361

Contributors

Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient. Node.js' package ecosystem, npm, is the largest ecosystem of open source libraries in the world.

Top Experts In
Node.js
<
Monthly
>