node.js – PHP upload via curl nodejs

Good night, I am trying for 2 days to send data from curl php to nodejs
When I lure outside, it works …
but I needed it to be like that ….
1 PHP trial:

       $this->ch = curl_init();
     curl_setopt($this->ch,CURLOPT_URL, $url);

  curl_setopt($this->ch,CURLOPT_POST, 1);
  curl_setopt($this->ch,CURLOPT_POSTFIELDS, $data);
  curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, true);
  curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, false);
  curl_setopt($this->ch, CURLOPT_POST, true);

  $result = curl_exec($this->ch);
 return curl_close($this->ch);

try 2:

    $ch = curl_init();
  curl_setopt($ch,CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
//curl_setopt($ch, CURLOPT_PORT, 2403);   //<----- Commented out !
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(    //<--- Added this code block
        'Content-Type: application/json',
        'Content-Length: ' . strlen($data))
$data = curl_exec($ch)|

In NodeJS, the post method in no way brings feedback that I've tried a little bit of everything and I lack ideas on how to do it or what I'm doing wrong. The cost of sending the ground goes, so I feel frustrated ... 4 days in trouble and I barely crawl on it ...'/teste', function (req, res,next) {

//   console.log(util.inspect(req));
//console.log(util.inspect(req, false, null, true /* enable colors */));;

  console.log('receiving data ...');
    console.log('body is ',req.body);


This method i can get the items and the return is ok:

app.get('/agencia2', function (req, res,next) {

//  console.log(req.params);
//  console.log(req.body);

   res.send("quase teste"); 

What version of Node.js can I use if I am stuck with SPFx v.1.1.0 (SP 2016)?

I am fixated on SharePoint 2016 for the time being and know that I no longer use SPFx v.1.1.0.

However, I am not sure what this means in relation to the version of Node.js to use.

I have some notes from a conference stating that Node LTS v.8 should be used, but my notes are not clear if this is the case exactly v.8 or at least v.8.

I'm asking because I have a non-SharePoint project that requires Node LTS v.10, and I'm trying to figure out if I can just upgrade to Node v.10 or if I need to install NVM and 10, depending on what I'm working on.

Does SPFx 1.1.0 work with Node LTS 10?

node.js – Why does Multer cause the error -4058 on nodeJS?

I'm trying to upload a picture along with its data. I use Multer to upload the picture. But I always get the following error message:

  (Error: ENOENT: no such file or directory, open 'D:worksfiverr-kiddiemmerce-beassetsproducts2019-09-13T16:18:26.393Z180911-Naver-x-Dispatch-Yeoreum-cosmic-girls-wjsn-41821990-2000-1333.jpg')
  errno: -4058,
  code: 'ENOENT',
  syscall: 'open',
  storageErrors: () 

How can I fix this? I have no idea at all. I have done so far.


const fs           = require('fs');
const multer       = require(`multer`);
const path         = require(`path`);
const productPath  = path.join(__dirname, `../../assets/products`);

const storage      = multer.diskStorage({
    destination: (req, file, cb) => {
        if (file.fieldname.includes(`material_image`)) {
            cb(null, materialPath);
        } else if (file.fieldname.includes(`product_image`)) {
            if (!fs.existsSync(productPath)) {
                fs.mkdir(productPath, { recursive: true }, (err) => {
            cb(null, productPath);
    filename: (req, file, cb) => {
        cb(null, new Date().toISOString() + file.originalname);
const filter    =  (req, file, cb) => {
    if (file.mimetype === `image/png` || file.mimetype === `image/jpeg`) {
        cb(null, true);
    } else {
        cb(null, false);

module.exports = {
    upload: multer({
        storage         : storage,
        limits          : { fileSize: 720 * 1280 * 5 },
        fileFilter  : filter,

and that's the productController.js (where I want to upload the image)

const { upload }      = require(`../utils/multer`);
const multer          = require(`multer`);

module.exports = {
   store: async (req, res) => {
        const img_upload = upload.any();
        img_upload(req, res, (err) => {
            if (err instanceof multer.MulterError) {
            } else if (err) {
                console.log(`It always goes here`);
            // Do something if no error

node.js – npm ERR! cb () never called! when trying to create a new Angular app

I tried to create a new Angular app for my web project at school, but I can not seem to be able to do so because of an unknown bug – cb () never called! I have a log of the console, but I can not find anything useful that I can use to fix the error. That's why I decided that I would post in forums and try to get posts from other users. Already posted in the npmcommunity forum, but I have no answers there yet.

After going through the normal process of creating a new app, I come to the last command "ng new angle-tour-of-heroes". After some time it goes with it

npm ERR! cb () never called!

npm ERR! This is a mistake at npm. Please report this error:
npm ERR!

npm ERR! A complete log of this run can be found in:
npm ERR! C: Users lache AppData Roaming npm-cache_logs 2019-09-11T16_05_41_529Z-debug.log
Package installation failed, see above.

The log is 866,000 characters long, so I can not paste it here and I'm not sure how to link it.

I'm running Node 10.16.3 and Npm 6.9.0.

If this is an inappropriate place to post, please tell me where it would be more appropriate.

nodejs – Respond and Firebase

I have doubts, I implement Firebase in my project. The truth seems to me to be a spectacular tool. The more I learn to use it, the more I love it.

Now I find a problem, the template or the form with which I take out a book … where we basically make an on (child_add) to recognize every single element of the array in real time, that's great, me subscribe to this feature when the UI is displayed and everything starts to load. There are certain things that are the truth that it does not help me to get from one to the other.
It would help me to get the entire document and to check if it changes after loading …

I know that with the function on (& 39; value & # 39;) I can import the entire document, but I want to know how you do it to get the best of both worlds … Do the pre -Load and then listen to the BD.

nodejs – Node: 12 processes are open at the same time

I've just completed the local configuration of a web application (tabulae) in Windows 10 running on Node.js (and MongoDB), and I think I did something wrong installing PM2 because it works on startup, but is provided twelve windows, so that:

Enter image description here

That there is no way to close, unless you restart the computer.

It's difficult to describe in detail what I did because it was quite awkward, and I suppose some of my multiple tests are causing the unanticipated, but I've written down the steps I feel appropriate to the process to repeat:

After installing Mongo, Node, restore the databases with a mongorestore and configure the files needed by the application to point in the appropriate direction.

  1. Install node dependencies (from the directory where they are located) package.json): npm install
  2. Install PM2: npm install pm2 -g
  3. Install PM2 as a Windows service: npm install pm2-windows-startup -g
  4. Configure PM2 to start Tabulae after starting / restarting the machine: pm2 startup install
  5. Start Tabulae with PM2 (from the directory where it is located) pm2-start.json): pm2 start pm2-start.json

And after this step, the twelve windows appear.

  1. Save the status of PM2 processes: pm2 save

If you restart the app using localhost and access it as needed, first reject the connection until the twelve windows appear. Then you can start working.

Can you imagine what might be due?

Greetings and thanks in advance.

node.js – How to create an organization where users share company data

Theoretically, how would you implement a model in which companies have their own "organization"? The users in this company have shared access to company data and have their own logins. Many companies do this, Salesforce … Netsuite …

If I wanted to do something similar with Nodejs and Express, where would I start?

If this is not the place for this kind of question, please let me know where I could research.

Many thanks

node.js – checking the crypto implementation?

I'm new to this arena and ask for feedback on a project I'm in charge of.

Although I'm not sure, implementing cryptographic functionality of node.j can be tricky, as it deals with different key sizes, IV sizes, encryption modes, input and output data types, and so on.

The "UNIX philosophy"drove the creation while the NIST SP 800 series from docs drove the design.

Most factors were taken into account; strong key derivation functionality, algorithm selection, appropriate algorithm modes corresponding to the specified key and IV sizes, optionally use of authentication tags and optional use of additional authentication data for the algorithms that support them.

I hope I can have more eyes to make sure the project complies with best practices. While opinions are important, solid criticism is what I'm looking for. If this is the wrong stack site, I'll move the question to another location.

The project can be found at @ kruptein, automatic code reviews @ codacy &

There is an associated test cable and the latest build results can be found at @travis-ci.

Help and feedback are welcome!

jquery – How ficJQuery CDN is not loaded into node.js app, which prevents the server from running

I started what I thought would be a simple shopping app. and across the board, I plan to add a feature to add some recipes, and then add the ingredients from the recipes to the shopping list.

I can not get my JQuery CD working on my landing page

I've tried to have the jquery cdn in the header header below in my html, and have tried all versions of jquery.

I have an index.js file for my entire app

var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var path = require('path');

var listAni = require('./public/js/list.js');

app.use(bodyParser.urlencoded({ extended: true }));
app.set('view engine', 'ejs');
app.use(express.static(__dirname + '/public'));

app.get('/', function(req, res) {

app.listen(process.env.PORT || 3000, function() {
    console.log('Express server listening on port %d in %s mode', this.address().port, app.settings.env);

then my home.ejs for my landing page






  • & # 39; apple & # 39;
  • & # 39; basil & # 39;
  • & # 39; almonds & # 39;
  • & # 39; milk & # 39;
  • & # 39; Butter & # 39;

and a list.js file to control the behavior of the landing

// Check Off Specific Todos By Clicking
$('ul').on('click', 'li', function() {

//Click on X to delete Todo
$('ul').on('click', 'span', function(event) {
    $(this).parent().fadeOut(500, function() {

$("input(type='text')").keypress(function(event) {
    if (event.which === 13) {
        //grabbing new todo text from input
        var todoText = $(this).val();
        //create a new li and add to ul
  • " + todoText + '
  • '); } }); $('.fa-plus').click(function() { $("input(type='text')").fadeToggle(); });

    I thought the JQuery commands would work, but that will not work.

    node.js – Set up Async for testing with Jest, Nodejs, Express, and Mongodb

    Hello, I am new to Javascript and develop an API-Rest with Nodejs, Express and Mongodb. While testing, I use Jest, Supertest, Factory Girl, Faker, and another instance of Mongodb in Docker, so I do not mock my database. My S.O. is Ubuntu.

    I'm having trouble completing the integration tests because I believe the bank data will be erased before each test.

    Whenever I run a test suite, everything happens normally.

    Enter image description here

    However, if I run all the test-suites concurrently, random errors will occur with respect to the data in the database.

    Enter image description here

    In this expression, the error was related to UserController.js, but sometimes errors occur in other controllers, and errors and files occur at random.

    I think it might have something to do with my database cleanup feature, it's an asynchronous function, and it seems to me that these errors occur because it takes a long time to run and clean up the database when you run a new test. which eventually invalidates the ongoing test.

    This is my jest setup file:

    import '../src/bootstrap';
    import databaseHelper from '../src/app/helpers/database';
    beforeAll(() => {
      return databaseHelper.connect();
    beforeEach(() => {
      return databaseHelper.truncate();
    afterAll(() => {
      return databaseHelper.disconnect();

    This is my database help:

    import mongoose from 'mongoose';
    import databaseConfig from '../../config/database';
    const connect = async () => {
      if (mongoose.connection.readyState === 0) {
        await mongoose.connect(databaseConfig.uri, databaseConfig.options);
    const truncate = async () => {
      const models = mongoose.connection.modelNames();
      const promises = model =>
      await Promise.all(promises);
    const disconnect = async () => {
      await mongoose.disconnect();
    export default {

    My database settings:

    export default {
      uri: process.env.DB_URL,
      options: {
        useCreateIndex: true,
        useNewUrlParser: true,
        useFindAndModify: false,

    In almost all my tests, I create a database record with Factory Girl and Faker and use Supertest to make a request and analyze the answer, as in the following example:

    it('should not be able to create user with duplicate email', async done => {
        const user = await'User');
        let response = await'/users').send({
          password: user.password,
        response = await'/users').send({
          password: user.password,
        expect(response.body).toHaveProperty('error', 'User already exists');

    This is the Factory Girl configuration:

    import faker from 'faker';
    import { factory, MongooseAdapter } from 'factory-girl';
    import User from '../src/app/models/User';
    import Habit from '../src/app/models/Habit';
    const adapter = new MongooseAdapter();
    factory.define('User', User, {
      password: faker.internet.password(),
    factory.define('Habit', Habit, {
      name: faker.lorem.word(),
      description: faker.lorem.sentence(),
    export default factory;

    These are my dependencies:

      "dependencies": {
        "bcryptjs": "^2.4.3",
        "dotenv": "^8.1.0",
        "express": "^4.17.1",
        "joi": "^14.3.1",
        "jsonwebtoken": "^8.5.1",
        "mongoose": "^5.6.11",
        "mongoose-paginate": "^5.0.3"
      "devDependencies": {
        "@sucrase/jest-plugin": "^2.0.0",
        "@types/jest": "^24.0.18",
        "eslint": "^6.3.0",
        "eslint-config-airbnb-base": "^14.0.0",
        "eslint-config-prettier": "^6.1.0",
        "eslint-plugin-import": "^2.18.2",
        "eslint-plugin-prettier": "^3.1.0",
        "factory-girl": "^5.0.4",
        "faker": "^4.1.0",
        "jest": "^24.9.0",
        "nodemon": "^1.19.1",
        "prettier": "^1.18.2",
        "sucrase": "^3.10.1",
        "supertest": "^4.0.2"

    The full code is on github:

    Can someone please tell me what I did wrong? Or give me suggestions for improvement?

    Another interesting point was that after running the tests multiple times, I noticed many processes running on my computer with the following commands:

    USER 999 COMANDO mongodb --bind_ip_all
    USER  COMANDO node_modulesjest-wo