我试图在Express 3中使用less
但我收到错误
节点v0.10.41中的" TypeError:path.join的参数必须是字符串"
在我的应用程序代码中:
app.use(less({
src : path.join(__dirname, 'public', 'less'),
dest : path.join(__dirname, 'public', 'css'),
prefix : '/css'
}));
这是我的Package.json
{
"name": "tolga",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node app.js"
},
"engines": {
"node": "0.10.41",
"npm": "1.4.29"
},
"dependencies": {
"async": "~0.2.9",
"bignum": "~0.6.1",
"body-parser": "^1.14.2",
"connect-redis": "~1.4.5",
"ejs": "*",
"express": "3.2.6",
"geolib": "~1.3.1"
}
}
答案 0 :(得分:0)
错误源于使用less
模块作为中间件。
适当的方法是使用less-middleware模块。安装后,您可以这种方式使用中间件:
// Install the 'less-middleware' module first
var lessMiddleware = require('less-middleware);
// 'less-middleware' takes the source as the first argument.
app.use(lessMiddleware(path.join(__dirname, 'public'), {
dest: path.join(__dirname, 'public', 'css'),
prefix: '/css'
}));