Comments (23)
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.
@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.
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.
Hey @xclusivzik , can you try module.exports = router;
as explained above?
Thanks.
from lumber.
@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.
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.
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.
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.
Thanks for report guys! I'll fix this!
from lumber.
@SeyZ thanks! now it is working!
from lumber.
Same here
from lumber.
Its not working guys..........
from lumber.
it's not working here..any one got the problem ?
from lumber.
Can you share your generated code to help me reproduce the issue? Thanks!
from lumber.
Thanks @cirokd - the documentation has been updated 👍
from lumber.
@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.
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.
Currently having the same issue
throw new TypeError('Router.use() requires a middleware function but got a ' + gettype(fn))
from lumber.
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.
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.
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.
Thanks @cirokd
from lumber.
/**
- 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)
- test-panel docker-compose app fails to start with a sequelize exception
- All of the feature links are broken(not found) on your github homepage HOT 1
- Lumber generate error: MongoError: value too large to reduce
- Extending rich text editor HOT 1
- There is no images inside https://docs.forestadmin.com/documentation/reference-guide/models HOT 1
- PostgreSQL, Generate a new backend application -> Error HOT 3
- DATABASE_URL hard-coded in docker-compose.yml HOT 1
- view codes does not work HOT 2
- Stuck Connection to database HOT 7
- Lumber not allowing pass-through of dialectOptions for Sequelize HOT 13
- (node:89175) UnhandledPromiseRejectionWarning: SequelizeAccessDeniedError: Access denied for user 'samplebloguser'@'localhost' (using password: YES) at ConnectionManager.connect HOT 1
- CRUD on mongoose dataBase with deepObject display "[Object, Object]" HOT 2
- Are there any plans to use typescript for Lumber, or are there any options there HOT 4
- Lumber generate fails with "Your database looks empty! Please create some collections before running the command."
- The automated release is failing 🚨
- Using GraphQL API as datasource
- Fix audit vulnerabilities for lodash and handlebars HOT 2
- Consider adding the Z SELinux label to the docker installation script
- throw new TypeError('Router.use() requires a middleware function but got a ' + gettype(fn))
- Error
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lumber.