my node virson is s (1)> node --version v14.17.3  npm verson is

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

i can run my file on the pc ,but when i uplode it to heroku ,ites not working ,and  it shows error code like this .

NPM_CONFIG_LOGLEVEL=error NODE_VERBOSE=false NODE_ENV=production NODE_MODULES_CACHE=true

 

 

my node virson is s (1)> node --version
v14.17.3

 npm verson is

matronics (1)> npm --version
6.14.13

 and i have write a nodejs package json like this .


{
"name": "LiveEmbellishedAnimatronics",
"version": "1.0.0",
"description": "",
"main": "app.js",
"dependencies": {
"body-parser": "^1.19.0",
"cookie-parser": "^1.4.5",
"express": "^4.17.1",
"express-session": "^1.17.2",
"http-errors": "^1.8.0",
"morgan": "^1.10.0",
"passport": "^0.5.0"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "webpack-dev-server --hot"
},
"keywords": [],
"author": "",
"license": "ISC"
}

-----------

my app js is like this 

var express = require('express');
  var exphbs = require('express-handlebars');
  var app = express();
  //app.engine('.hbs', exphbs({extname: '.hbs'}));
  //app.set('view engine', '.hbs');
  app.engine('hbs', exphbs({defaultLayout: false, extname:'.hbs',}));
  const bodyParser = require("body-parser");
  const fs = require("fs");
  var createError = require("http-errors");
  const passport = require("passport");
  var path = require("path");
  const session = require("express-session");
  var cookieParser = require("cookie-parser");
  var logger = require("morgan");
  var express = require('express');
  var exphbs = require('express-handlebars');
  app.set("views", path.join(__dirname, "views"));
  app.set("view engine", "hbs");
  app.use(logger("dev"));
  app.use(express.json());
  app.use(express.urlencoded({ extended: false }));
  app.use(cookieParser());
  app.use(express.static(path.join(__dirname, "public")));
  app.use(express.static("./public"));
  app.use(bodyParser.urlencoded({ extended: false }));
  app.use(bodyParser.json());
  var userLogin = {};
  app.post("/api/login", (req, res) => {
  fs.readFile("./data.json", (err, data) => {
  var arr = [];
  if (err) {
  console.log(err);
  } else {
  if (data.toString()) {
  arr = JSON.parse(data.toString());
  }
  var s = arr.find((item) => {
  if (item.name == req.body.name) {
  return item;
  }
  });
  if (s) {
  if (s.password == req.body.password) {
  userLogin = req.body;
  res.json({
  status: "y",
  meg: "login success",
  data: s.name,
  });
  } else {
  res.json({
  status: "err",
  meg: "wrong password ",
  });
  }
  } else {
  res.json({
  status: "n",
  meg: "no such user ",
  });
  }
  }
  });
  });
   
  app.get("/index", (req, res) => {
  if (userLogin.name) res.render("index", { username: userLogin.name });
  else res.render("login");
  });
   
  app.get("/", (req, res) => {
  res.render("login");
  });
   
   
  app.set("views", path.join(__dirname, "views"));
   
  app.use(express.static(path.join(__dirname, "public")));
   
   
   
   
   
  var PORT = 3000;
  app.listen(3000, function () {
  console.log(`Listening on port ${PORT}`);
 

});

 

 

 

 

 

 

 

 

 

 

 

 

 

Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education