Most Popular Tutorials
Most Popular Tutorials :-

Simply Easy Learning at Your Fingertips. Click Tutorials Menu to view More Tutorial List





Node Js problems and Solutions (Node Js Errors Solutions)

Error :-

npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm WARN deprecated tar@2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.

changed 67 packages, and audited 68 packages in 4s

4 packages are looking for funding
run `npm fund` for details

2 high severity vulnerabilities

Some issues need review, and may require choosing
a different dependency.

Run `npm audit` for details.



Solution :-
  • Step 1: Go to the \nodejs folder and open the two files npm.cmd and npm by a text editor

  • Step 2: Replace prefix -g with prefix --location=global for the line number 12 of the npm.cmd file and line number 23 of the npm file





  • Error :-

    app.set('port', port);
    ^

    TypeError: app.set is not a function
    at Object. (/home/xpuser/Desktop/Nodetest/bin/www:16:5)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Function.Module.runMain (module.js:441:10)
    at startup (node.js:139:18)
    at node.js:968:3

    Solutions :-
    var express = require('express');
    var app = express();

    var port = "1000";
    app.set('port', port);

    module.exports = app;

    Error and soluton :-

    npm ERR! code ENOVERSIONS
    npm ERR! No valid versions available for dateFormat

    npm ERR! A complete log of this run can be found in:
    npm ERR! /root/.npm/_logs/2019-05-24T04_43_53_179Z-debug.log



    Solutions :-

    npm install dateformat

    var dateFormat = require('dateformat');




    mysql query issue:-

    var user_name = "sana";

    "SELECT * FROM ittutorial WHERE name = '" +user_name + "'"


    "SELECT * FROM ittutorial WHERE name = '" + connection.escape(user_name) + "'"


    app.get("/ittutorial/:tutorial", cors(), function(req, res) {
    var user_name = req.params.user_name;

    var sql = "SELECT * FROM ittutorial WHERE name = ?";
    connection.query(sql, user_name, function(err, rows, fields) {
    });
    });


    // If you have multiple substitutions to make, use an array:
    app.get("/arrivals/:flightNo", cors(), function(req, res) {
    var user_name= req.params.user_name;
    var age= req.query.age;

    var sql = "SELECT * FROM ittutorial WHERE name = ? AND age >= ?";
    connection.query(sql, [ user_name, age], function(err, rows, fields) {
    });
    });













    Previous Next


    Trending Tutorials




    Review & Rating

    0.0 / 5

    0 Review

    5
    (0)

    4
    (0)

    3
    (0)

    2
    (0)

    1
    (0)

    Write Review Here