Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: express is not a function

Hi I'm trying to use jade and express together. But it is giving me TypeError. I made npm init, npm install express -save and then node app.js. But it is giving me same error "TypeError: express is not a function"

// Module dependencies
var express = require('express')
  , nib = require('nib')
  , mysql = require('mysql')

 var app = express();

var app = module.exports = app.createServer();


app.set('views', __dirname + '/views')
app.set('view engine', 'jade')
app.use(express.logger('dev'))

And package.json :

{
  "name": "reddit-node-mysql",
  "description": "A demo of how to use Express and MySQL together",
  "author": "Clarence Leung <github@clarle>",
  "version": "0.0.1",
  "private": true,
  "dependencies": {
    "express": "^2.5.11",
    "mysql": "~2.0",
    "nib": "^1.1.2",
    "jade": "^1.0.4"
  },
  "main": "app.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "license": "ISC",
  "devDependencies": {}
}

Solution My modules' version outdated so they can't installed well. I updated version of them, now working.

like image 964
emrece Avatar asked Nov 16 '17 11:11

emrece


People also ask

What does TypeError X is not a function mean?

TypeError: "x" is not a function The JavaScript exception "is not a function" occurs when there was an attempt to call a value from a function, but the value is not actually a function.

What does the JavaScript exception'is not a function'mean?

The JavaScript exception "is not a function" occurs when there was an attempt to call a value from a function, but the value is not actually a function. What went wrong? It attempted to call a value from a function, but the value is not actually a function. Some code expects you to provide a function, but that didn't happen.

What does the JavaScript error “is not a function” mean?

The JavaScript exception "is not a function" occurs when there was an attempt to call a value from a function, but the value is not actually a function. Message TypeError: Object doesn't support property or method {x} (Edge) TypeError: "x" is not a function

How do I fix TypeError date formt is not a function?

Throws 'TypeError: date.formt is not a function' date.formt ('YYYY-MM-DD'); If JavaScript throws this error in code that you wrote, you should double check the code at the line number in the error's stack trace.


1 Answers

You are using outdated express ,

Remove
"express": "^2.5.11", from package json and run

npm install --save express

like image 144
Himanshu sharma Avatar answered Oct 21 '22 12:10

Himanshu sharma