express

Error while pushing to Heroku: Cannot find module 'node-linux-x64/package.json'

拜拜、爱过 提交于 2020-06-01 03:17:09
问题 When deploying a fullstack Javascript app to Heroku, I receive the following error: Error: Cannot find module 'node-linux-x64/package.json' There's also a syntax error, but I don't believe that's the cause. I'm a Mac user, so I'm unsure of what's going on. I've checked for the syntax error, but found nothing. I also tried uninstalling and reinstalling Node, etc... Output: remote: -----> Installing dependencies remote: Prebuild detected (node_modules already exists) remote: Rebuilding any

How to use MongoDB change streams with node js via a REST API microservice (built with Express)

大兔子大兔子 提交于 2020-05-31 04:43:42
问题 I'm using react js for building frontend for a website. An express server (which is a microservice) sits in between the front end and MongoDB. I make Axios calls from react js to express server (URL = http://localhost:5688/chat ) using GET, POST, PUT whenever and wherever needed. something like below Client side var resp = axios.get(`http://localhost:5688/chat`); resp.then((response) => { this.setState({data: response.data}) }) Server side app.js var app = express(); app.get('/chat', function

Express.js blogging application bug: filtering posts by category throws “Cast to ObjectId failed” failed error

六眼飞鱼酱① 提交于 2020-05-30 10:23:06
问题 I am working on a blogging application (click the link to see the GitHub repo) with Express, EJS and MongoDB. I have Posts that are grouped into Categories , each in its own collection. I run into a problem trying to filter posts by category. To obtain the post by category url, I turn the category name into a slug and use it this way: Posted in <a href="/<%= post.category.cat_name.replace(/\s+/g, '-').toLowerCase(); %>"><%= post.category.cat_name %></a> In the public routes file I have: const

Express Validator Cannot Show Error Mesages

…衆ロ難τιáo~ 提交于 2020-05-30 08:49:22
问题 Hey guys I want to make an messaging system for my upload webpage. I use express-validator and connect-flash, express-messages app.js const { check, validationResult } = require('express-validator'); . . . app.post('/metin/ekle', [ // username must be an email check('baslik', 'Baslik Gereklidir').notEmpty(), // password must be at least 5 chars long check('konu','Konu gereklidir').notEmpty(), ],function(req, res){ const errors = validationResult(req); if (!errors.isEmpty()) { req.flash(

socket.io net::ERR_CONNECTION_CLOSED

↘锁芯ラ 提交于 2020-05-29 06:52:36
问题 I am creating a multiplayer game with login system. However, there is one error, which I don't know how to solve. When I run my app I get the following error: net::ERR_CONNECTION_CLOSED. Here is my app.js var express = require('express'); var path = require('path'); var cookieParser = require('cookie-parser'); var bodyParser = require('body-parser'); var exphbs = require('express-handlebars'); var expressValidator = require('express-validator'); var flash = require('connect-flash'); var

socket.io net::ERR_CONNECTION_CLOSED

别说谁变了你拦得住时间么 提交于 2020-05-29 06:51:17
问题 I am creating a multiplayer game with login system. However, there is one error, which I don't know how to solve. When I run my app I get the following error: net::ERR_CONNECTION_CLOSED. Here is my app.js var express = require('express'); var path = require('path'); var cookieParser = require('cookie-parser'); var bodyParser = require('body-parser'); var exphbs = require('express-handlebars'); var expressValidator = require('express-validator'); var flash = require('connect-flash'); var

Mongoose findbyid() return null

牧云@^-^@ 提交于 2020-05-29 06:43:07
问题 I am trying to find a record in my mongo db by its id No matter I use findbyid(), findone(id,...), it return null here is my code. what is the solution? const mongoose = require('mongoose'); mongoose.connect('mongodb://localhost/Movie', {useNewUrlParser: true}) .then(() => console.log('Connected to Databse')) .catch(err => console.err('Could not connect to MongoDB', err)); var ObjectId = require('mongodb').ObjectID; const Schema = new mongoose.Schema({ name: String, author: String, tags:

How can I pass Express.js variables to MongoDB functions?

坚强是说给别人听的谎言 提交于 2020-05-29 06:24:31
问题 I am working on a blogging application (click the link to see the GitHub repo) with Express, EJS and MongoDB. I have made a simple pager for the posts. In the posts controller I have: exports.getPosts = async (req, res, next) => { const posts = await Post.find({}, (err, posts) => { const perPage = 10; const currPage = req.query.page ? parseInt(req.query.page) : 1; const postsCount = posts.length; const pageCount = Math.ceil(postsCount / perPage); const pageDecrement = currPage > 1 ? 1 : 0;

Post request Axios : Network error

人走茶凉 提交于 2020-05-29 05:23:14
问题 I'm using NodeJS for the backend, and ReactJS for the frontend. I've a problem with request Axios network. All my Get request work. But Post request don't work. I have just this error "network error" I created a simple webservice to show you my problem : //Serveur code helloWs : (request:Express.Request, response:Express.Response) => { try { response.send('hello WS !') } catch (error) { console.error(error) response.send('error' + error + 'status : ' + error.response.status) response.end() }

Sequelize error: defineCall not defined in Index.js

假如想象 提交于 2020-05-29 03:59:02
问题 I've been receiving this sequelize error /node_modules/sequelize/lib/sequelize.js:508 this.importCache[path] = defineCall(this, DataTypes); ^ TypeError: defineCall is not a function at module.exports.Sequelize.import (/node_modules/sequelize/lib/sequelize.js:508:32) at /models/Index.js:16:33 at Array.forEach (native) at Object.<anonymous> (/Users/vincentporta/Desktop/RCB_Classwork/cesarcell/models/Index.js:15:4) at Module._compile (module.js:409:26) at Object.Module._extensions..js (module.js