问题描述
我目前正在开发一个express.js Webapp,我正在使用MS Webmatrix附带的样板应用程序。我能够在我的计算机上运行应用程序,但是当我推送到nodejitsu或使用另一台我从git获得应用程序的计算机时,我得到一个错误,阻止服务器启动。
I am currently working on an express.js Webapp, Im working off the boilerplate app that comes with MS Webmatrix. I am able to run the app on my computer but when i push to nodejitsu or use another computer from which i got the app from git i get an error preventing server start.
app.use(express.compiler({ src: __dirname + '/public', enable: ['less'] })
^
TypeError: Object function createApplication() {
var app = connect();
utils.merge(app, proto);
app.request = { __proto__: req };
app.response = { __proto__: res };
app.init();
return app;
} has no method 'compiler'
at Function.<anonymous> (C:\Users\hoopdog2\Desktop\afterthoughts_nodejs\serv
er.js:197:21)
at Function.app.configure (C:\Users\hoopdog2\Desktop\afterthoughts_nodejs\no
de_modules\express\lib\application.js:399:61)
at Object.<anonymous> (C:\Users\hoopdog2\Desktop\afterthoughts_nodejs\server
.js:188:5)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.runMain (module.js:492:10)
at process.startup.processNextTick.process._tickCallback (node.js:244:9)
该应用程序使用的依赖项
The dependencies that that app uses are
"node-uuid": ">= 1.3.3",
"everyauth": ">= 0.2.29",
"nconf": ">= 0.5.1",
"express": ">= 2.5.0",
"jade": ">= 0.18.0",
"less": ">= 1.1.5",
"socket.io": ">= 0.8.7",
"connect": ">=1.8.5",
"recaptcha": ">=1.1.0"
我正在使用节点版本0.8.7。非常感谢任何可能导致此错误的建议
And i am using node version 0.8.7. Any suggestions to what might be causing this error is greatly appreciated
推荐答案
编译器
Express的中间件来自Connect框架,截至2011年7月Connect不再包含编译器
。因此, express.compiler(...)
不再有效。
The compiler
middleware for Express comes from the Connect framework and as of Jul 2011 Connect no longer includes compiler
. So doing express.compiler(...)
doesn't work anymore.
一个特定于LESS的中间件已创建,Express现在使用它,如果您将其包含在您的启动配置中。 express -c less
将此行添加到配置中:
A LESS-specific middleware has been created and Express now uses that if you include it in your startup config. express -c less
will add this line to the config:
app.use(require('less-middleware')({ src: __dirname + '/public' }));
如果你有旧版本的Express和Connect,你可以添加更少-middleware
到您的 package.json
并添加上面的行以使其正常工作。
If you have an older version of Express and Connect, you can add less-middleware
to your package.json
and add the line above to get it working.
它与原始编译器的工作原理基本相同,但包括更多的花哨功能。
It works pretty much the same as the original compiler, but includes some more bells and whistles.
这篇关于节点js express.compiler错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!