警告:connect.static不是函数使用--force继续 [英] Warning: connect.static is not a function Use --force to continue
问题描述
我正在使用YO lessapp项目,grunt-contrib-connect帮助我在9000端口上启动一个节点js服务器。
运行connect:livereload服务, (连接)任务
警告:connect.static不是函数使用--force继续。
确切的错误发生在Gruntfile.js的下面的函数中:
livereload:{
options:{
middleware:function(connect){
return [
connect.static ('.tmp'),
connect()。use('/ bower_components',connect.static('./ bower_components')),
connect.static(config.app)
]。
}
}
},
我已经安装了
npm install grunt-contrib-connect --save-dev
,
npm install serve-static --save-dev
我遇到过几个帖子,有人建议关闭防火墙,但没有运气。
<我知道我的机器或npm / node / connect版本有冲突,因为我试图从其他机器运行相同的应用程序,并且工作正常。
系统配置:
- Windows 7专业版
- 节点-v4.1.2
- npm -v2.14.4
- connect@3.4.0
- connect@3.4.0
我已经安装了基于post的 nodejs connect无法找到静态的connect和serve-static。 ,但仍然相同
有什么帮助?提前致谢
您必须安装 connect
和 serve-static
:
npm install --save-dev grunt-contrib-connect serve-static
然后您必须导入 serve-static
in Gruntfile.js
:
module.exports =函数(grunt){
...
var serveStatic = require('serve-static');
grunt.initConfig({
...
connect:{
...
livereload:{
options:{
middleware:function(connect){
return [
serveStatic('。tmp'),
connect()。use('/ bower_components',serveStatic('./ bower_components') ),
serveStatic(config.app)
;
}
}
}
I am using YO lessapp project, "grunt-contrib-connect" helps me to start a node js server on 9000 port. Whenever I run grunt serve (start the server) the service is aborted due to the below warning.
Running "connect:livereload" (connect) task
Warning: connect.static is not a function Use --force to continue.
The exact error took place in the below function in Gruntfile.js
livereload: {
options: {
middleware: function(connect) {
return [
connect.static('.tmp'),
connect().use('/bower_components', connect.static('./bower_components')),
connect.static(config.app)
];
}
}
},
I have installed
npm install grunt-contrib-connect --save-dev
,
npm install serve-static --save-dev
I came across few post, some suggest to turn off the firewall but no luck.
I know there is something to do with my machine or npm/node/connect version conflicts, because I tried to run the same app from other machine and it works fine.
System configuration :
- Windows 7 Professional
- Node -v4.1.2
- npm -v2.14.4
- connect@3.4.0
I have installed connect and serve-static based upon the post nodejs connect cannot find static, but still the same
Any help? Thanks in Advance
You have to install connect
and serve-static
:
npm install --save-dev grunt-contrib-connect serve-static
And then you have to import serve-static
in Gruntfile.js
:
module.exports = function (grunt) {
...
var serveStatic = require('serve-static');
grunt.initConfig({
...
connect: {
...
livereload: {
options: {
middleware: function(connect) {
return [
serveStatic('.tmp'),
connect().use('/bower_components', serveStatic('./bower_components')),
serveStatic(config.app)
];
}
}
}
这篇关于警告:connect.static不是函数使用--force继续的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!