GithubHelp home page GithubHelp logo

Comments (23)

cirokd avatar cirokd commented on July 19, 2024 16

I had this problem when creating a new file in the routes folder according to the documentation:

/* /routes/whoami.js */
const express = require('express');
const router = express.Router();
const Liana = require('forest-express-sequelize');

router.get('/actions/whoami', Liana.ensureAuthenticated, (req, res) => {
  res.send({ success: `You are ${req.user.data.first_name} ${req.user.data.last_name}.` });
});

What's missing is the last line:

module.exports = router;

If anyone still having this issue ran into it by creating a route file, this should fix it.

from lumber.

SeyZ avatar SeyZ commented on July 19, 2024 3

@django-wong @barohatoum @base16soft It's now fixed in the version 1.0.10.

  • You can upgrade using npm install -g lumber-cli@latest and regenerate your admin microservice
    or
  • You can add in your admin generated folder, modify the app.js file according to this change: d4225b8#diff-fb096da81ac8de5f55989e87d728ca53R32

Feel free to reopen if the problem still appears. Thanks!

from lumber.

augustocsmartins avatar augustocsmartins commented on July 19, 2024 2

same here.
Ubuntu 14
npm 3.8.6
node v5.11.1

/home/augustoc/hellotickets-admin/HelloTickets/node_modules/express/lib/router/index.js:458
throw new TypeError('Router.use() requires middleware function but got a ' + gettype(fn));
^

TypeError: Router.use() requires middleware function but got a Object
at Function.use (/home/augustoc/hellotickets-admin/HelloTickets/node_modules/express/lib/router/index.js:458:13)
at EventEmitter. (/home/augustoc/hellotickets-admin/HelloTickets/node_modules/express/lib/application.js:219:21)
at Array.forEach (native)
at EventEmitter.use (/home/augustoc/hellotickets-admin/HelloTickets/node_modules/express/lib/application.js:216:7)
at /home/augustoc/hellotickets-admin/HelloTickets/app.js:32:7
at Array.forEach (native)
at Object. (/home/augustoc/hellotickets-admin/HelloTickets/app.js:31:28)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)

from lumber.

arnaudbesnier avatar arnaudbesnier commented on July 19, 2024 1

Hey @xclusivzik , can you try module.exports = router; as explained above?

Thanks.

from lumber.

xclusivzik avatar xclusivzik commented on July 19, 2024 1

@arnaudbesnier i did that already still the same issue,
" throw new TypeError('Router.use() requires a middleware function but got a ' + gettype(fn))"

from lumber.

arnaudbesnier avatar arnaudbesnier commented on July 19, 2024 1

Hi @sandeep318kumar,

Did you add customisation to your Lumber generated NodeJS app?
Could you share you app.js code to investigate your issue?

Thanks for your help.

from lumber.

goldbright00000 avatar goldbright00000 commented on July 19, 2024 1

this is my app.js file.
i got same issue like above .

how can i solve this issue ?

[email protected] start G:\upwork\UltraNoteI-Cloud\cryptwallet-admin
cross-env NODE_ENV=development node server

G:\upwork\UltraNoteI-Cloud\cryptwallet-admin\node_modules\express\lib\router\index.js:458
throw new TypeError('Router.use() requires a middleware function but got a ' + gettype(fn))
^

TypeError: Router.use() requires a middleware function but got a Object
at Function.use (G:\upwork\UltraNoteI-Cloud\cryptwallet-admin\node_modules\express\lib\router\index.js:458:13)
at Function. (G:\upwork\UltraNoteI-Cloud\cryptwallet-admin\node_modules\express\lib\application.js:220:21)
at Array.forEach ()
at Function.use (G:\upwork\UltraNoteI-Cloud\cryptwallet-admin\node_modules\express\lib\application.js:217:7)
at Object. (G:\upwork\UltraNoteI-Cloud\cryptwallet-admin\server\index.js:30:5)
at Module._compile (node:internal/modules/cjs/loader:1108:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
at Module.load (node:internal/modules/cjs/loader:973:32)
at Function.Module._load (node:internal/modules/cjs/loader:813:14)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
at node:internal/main/run_main_module:17:47
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: cross-env NODE_ENV=development node server
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\fulls\AppData\Roaming\npm-cache_logs\2021-01-06T05_56_43_703Z-debug.log

from lumber.

barohatoum avatar barohatoum commented on July 19, 2024

SAME HERE

OS Type: macOS Sierra 10.12.1
Node: 7.1.0
NPM: 3.10.9

/Users/ibrahimhatoum/Sites/www/sportsadmin/node_modules/express/lib/router/index.js:458 throw new TypeError('Router.use() requires middleware function but got a ' + gettype(fn)); ^ TypeError: Router.use() requires middleware function but got a Object at Function.use (/Users/ibrahimhatoum/Sites/www/sportsadmin/node_modules/express/lib/router/index.js:458:13) at Function.<anonymous> (/Users/ibrahimhatoum/Sites/www/sportsadmin/node_modules/express/lib/application.js:219:21) at Array.forEach (native) at Function.use (/Users/ibrahimhatoum/Sites/www/sportsadmin/node_modules/express/lib/application.js:216:7) at fs.readdirSync.forEach (/Users/ibrahimhatoum/Sites/www/sportsadmin/app.js:32:7) at Array.forEach (native) at Object.<anonymous> (/Users/ibrahimhatoum/Sites/www/sportsadmin/app.js:31:28) at Module._compile (module.js:573:32) at Object.Module._extensions..js (module.js:582:10) at Module.load (module.js:490:32)

from lumber.

SeyZ avatar SeyZ commented on July 19, 2024

Thanks for report guys! I'll fix this!

from lumber.

augustocsmartins avatar augustocsmartins commented on July 19, 2024

@SeyZ thanks! now it is working!

from lumber.

nitinmaram avatar nitinmaram commented on July 19, 2024

Same here

from lumber.

sreenathe12 avatar sreenathe12 commented on July 19, 2024

Its not working guys..........

from lumber.

Kiranyellu avatar Kiranyellu commented on July 19, 2024

it's not working here..any one got the problem ?

from lumber.

SeyZ avatar SeyZ commented on July 19, 2024

Can you share your generated code to help me reproduce the issue? Thanks!

from lumber.

SeyZ avatar SeyZ commented on July 19, 2024

Thanks @cirokd - the documentation has been updated 👍

from lumber.

MiraiTunga avatar MiraiTunga commented on July 19, 2024

@SeyZ The current documentation seems to not have this update the module.exports = router; line is missing from

https://doc.forestadmin.com/developer-guide/express-sequelize.html#example-banning-a-user

from lumber.

xclusivzik avatar xclusivzik commented on July 19, 2024

i have the same issue
here is the error i encounter

$ node server.js
This is an app!
C:\Users\Desktop\Node.js\chatcat\node_modules\express\lib\router\index.js:458
throw new TypeError('Router.use() requires a middleware function but got a ' + gettype(fn))
^

TypeError: Router.use() requires a middleware function but got a undefined
at Function.use (C:\Users\MFM lekki\Desktop\Node.js\chatcat\node_modules\express\lib\router\index.js:458:13)
at Function. (C:\Users\MFM lekki\Desktop\Node.js\chatcat\node_modules\express\lib\application.js:220:21)
at Array.forEach ()
at Function.use (C:\Users\MFM lekki\Desktop\Node.js\chatcat\node_modules\express\lib\application.js:217:7)
at Object. (C:\Users\Desktop\Node.js\chatcat\server.js:12:5)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)


my code
'use strict';
const router = require('express').Router();

router.get('/', (req, res, next) => {

res.render('login');

});

module.exports = {
router: router
}

from lumber.

kyle-fitz avatar kyle-fitz commented on July 19, 2024

Currently having the same issue
throw new TypeError('Router.use() requires a middleware function but got a ' + gettype(fn))

from lumber.

prateekvyas2121 avatar prateekvyas2121 commented on July 19, 2024

how can i solve it..???..yesterday it was working fine but today morning i don't know what happened to this....

TypeError: Router.use() requires a middleware function but got a string
at Function.use (C:\Users\DELL\Desktop\node_passport_login\node_modules\express\lib\router\index.js:458:13)
at Function. (C:\Users\DELL\Desktop\node_passport_login\node_modules\express\lib\application.js:220:21)
at Array.forEach ()
at Function.use (C:\Users\DELL\Desktop\node_passport_login\node_modules\express\lib\application.js:217:7)
at Object. (C:\Users\DELL\Desktop\node_passport_login\app.js:23:5)
at Module._compile (internal/modules/cjs/loader.js:956:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
at Module.load (internal/modules/cjs/loader.js:812:32)
at Function.Module._load (internal/modules/cjs/loader.js:724:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1025:10)
at internal/main/run_main_module.js:17:11
[nodemon] app crashed - waiting for file changes before starting...

from lumber.

arnaudbesnier avatar arnaudbesnier commented on July 19, 2024

Hi @prateekvyas2121,
This is not the exact same error message and, thus, probably not the same issue origin.
Please take the time to detail your issue in another ticket.

(Odds are very hight that such issue is related to code or dependencies changes on you end, especially if the code was working well yesterday)

from lumber.

sandeep318kumar avatar sandeep318kumar commented on July 19, 2024

Got this error while starting the server.
Node app.js

C:\Users\abc\Documents\HTML\backend start\yelpCamp\node_modules\express\lib\router\index.js:458
throw new TypeError('Router.use() requires a middleware function but got a ' + gettype(fn))
^

TypeError: Router.use() requires a middleware function but got a Object
at Function.use (C:\Users\abc\Documents\HTML\backend start\yelpCamp\node_modules\express\lib\router\index.js:458:13)
at Function. (C:\Users\abc\Documents\HTML\backend start\yelpCamp\node_modules\express\lib\application.js:220:21)
at Array.forEach ()
at Function.use (C:\Users\abc\Documents\HTML\backend start\yelpCamp\node_modules\express\lib\application.js:217:7)
at Object. (C:\Users\abc\Documents\HTML\backend start\yelpCamp\app.js:68:5)
at Module._compile (internal/modules/cjs/loader.js:955:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
at Module.load (internal/modules/cjs/loader.js:811:32)
at Function.Module._load (internal/modules/cjs/loader.js:723:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)
at internal/main/run_main_module.js:17:11

from lumber.

jyotsana-khaparde avatar jyotsana-khaparde commented on July 19, 2024

Thanks @cirokd

from lumber.

goldbright00000 avatar goldbright00000 commented on July 19, 2024

/**

  • app.js
  • This is the entry file for the application, only setup and boilerplate
  • code.
    */

// Needed for redux-saga es6 generator support
import '@babel/polyfill';

// Import all the third party stuff
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { ConnectedRouter } from 'connected-react-router';
import history from 'utils/history';
import 'sanitize.css/sanitize.css';

// Import root app
import App from 'containers/App';

// Import Language Provider
import LanguageProvider from 'containers/LanguageProvider';

// Load the favicon and the .htaccess file
/* eslint-disable import/no-unresolved, import/extensions /
import 'file-loader?name=.htaccess!./.htaccess';
/
eslint-enable import/no-unresolved, import/extensions */

import configureStore from './configureStore';

// Import i18n messages
import { translationMessages } from './i18n';

// Create redux store with history
const initialState = {};
const store = configureStore(initialState, history);
const MOUNT_NODE = document.getElementById('app');

const render = messages => {
ReactDOM.render(






,
MOUNT_NODE,
);
};

if (module.hot) {
// Hot reloadable React components and translation json files
// modules.hot.accept does not accept dynamic dependencies,
// have to be constants at compile-time
module.hot.accept(['./i18n', 'containers/App'], () => {
ReactDOM.unmountComponentAtNode(MOUNT_NODE);
render(translationMessages);
});
}

// Chunked polyfill for browsers without Intl support
if (!window.Intl) {
new Promise(resolve => {
resolve(import('intl'));
})
.then(() => Promise.all([import('intl/locale-data/jsonp/en.js')]))
.then(() => render(translationMessages))
.catch(err => {
throw err;
});
} else {
render(translationMessages);
}

// Install ServiceWorker and AppCache in the end since
// it's not most important operation and if main code fails,
// we do not want it installed
if (process.env.NODE_ENV === 'production') {
require('offline-plugin/runtime').install(); // eslint-disable-line global-require
}

from lumber.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.