npm run prd 报错
来源:10-14 使用morgan写日志
LC1243208
2019-04-30
npm run dev:可正常运行
package.json 配置如下
{
"name": "blog-express",
"version": "0.0.0",
"private": true,
"scripts": {
"dev": "cross-env NODE_ENV=development nodemon ./bin/www",
"prd": "cross-env NODE_ENV=production nodemon ./bin/www"
},
"dependencies": {
"connect-redis": "^3.4.1",
"cookie-parser": "~1.4.3",
"debug": "~2.6.9",
"express": "~4.16.0",
"express-session": "^1.16.1",
"http-errors": "~1.6.2",
"jade": "~1.11.0",
"morgan": "~1.9.0",
"mysql": "^2.17.1",
"redis": "^2.8.0",
"xss": "^1.0.6"
},
"devDependencies": {
"cross-env": "^5.2.0",
"nodemon": "^1.18.11"
}
}
报错内容如下:
e:\03-MY\Node\NodeDemo\05.blog.express\blog-express\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 (e:\03-MY\Node\NodeDemo\05.blog.express\blog-express\node_modules\express\lib\router\index.js:458:13)
at Function.<anonymous> (e:\03-MY\Node\NodeDemo\05.blog.express\blog-express\node_modules\express\lib\application.js:220:21)
at Array.forEach (<anonymous>)
at Function.use (e:\03-MY\Node\NodeDemo\05.blog.express\blog-express\node_modules\express\lib\application.js:217:7)
at Object.<anonymous> (e:\03-MY\Node\NodeDemo\05.blog.express\blog-express\app.js:30:7)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
[nodemon] app crashed - waiting for file changes before starting...
写回答
1回答
-
提示 Router.use() requires a middleware function but got a Object 。你看一下路由中间件返回的是不是 function ?其中一个路由中间件可能返回的是 object 。
132024-01-12
相似问题
npm run prd报错
回答 2
环境参数获取不到
回答 2