Tag: 节点.js

在Diet.js头文件中删除x-powered-by和Server

我使用diet.js为http内容提供服务,但是我想从http响应中删除x-powered-by头和Server头。 有没有办法可以做到这一点,而无需编辑模块的来源?

如何通过Web浏览器访问node.js脚本?

我正在尝试使用lesscss服务器端。 它需要Node.js,我已经安装了它,看了一些教程,但现在我不知道如何使用它。 在你创build一个服务器/ TCP或任何如何从你的网站得到它? 我希望能够像mywebsite.com/css那样做,当我去那里它会输出node.js告诉它的CSS。

在脚手架复合js的路线中拼写错误问题

我是新的节点和复合。 当我试图脚手架 compound g crud leaveApplication leave_code:string description:string applicable:string carry_forward:boolean limit_type:boolean lop:boolean od:boolean co:boolean leave_revision:boolean active:boolean 我得到一些错误,然后我尝试了 compound g crud leave code:string description:string applicable:string cForward:boolean limit:boolean lop:boolean od:boolean co:boolean leave_revision:boolean active:boolean 但现在发生的错误是以路线的名义 leaves GET /leaves.:format? leaves#index leaves POST /leaves.:format? leaves#create new_leafe GET /leaves/new.:format? leaves#new edit_leafe GET /leaves/:id/edit.:format? leaves#edit leafe DELETE /leaves/:id.:format? leaves#destroy leafe PUT /leaves/:id.:format? […]

在node.js中定制validation消息

我是Node.js的新手,并且在node.js.中定制validation消息时遇到了问题。我使用CRUD操作创build了一个使用Compound JS的简单应用程序。 在我的应用程序中有一个名为“ID”的字段。 “id”字段只接受整数值。 然后我通过在model / user.js中使用以下代码来validation该字段。 module.exports = function (compound, User) { var num = /^\s*\d+\s*$/; User.validatesFormatOf('id', {with: num, message:"is not a number"}); }; 通过使用上面的代码,它工作正常。 但是我也想检查一下这个字段是否为空。 然后我稍微改变一下代码。 修改后的代码如下所示: module.exports = function (compound, User) { var num = /^\s*\d+\s*$/; User.validatesFormatOf('id', {with: num, message: {blank: "can't be blank", with: "is not a number"}}); }; 然后validation消息,如果该字段为空,将显示为“Id不能为空”。 但是,当我input除数字以外的id字段中的值时,validation错误消息将是“Id […]

与when.js如何将一个承诺转换为一个Node.js风格的callback?

我正在使用IcedCoffeeScript。 我想写这个: User.find(id).always esc done或await User.find(id).always defer e, user 但是Promise#always在when.js被弃用。 有另一种方法吗?

减lessCSS和和节点的麻烦

当我尝试在我的Ubuntu 13.10框下安装较less的css编译器时,我得到以下消息,lescss不工作。 我能以什么方式解决问题? 我执行: sudo npm install -g less 在这之后,我用OK消息得到e列表: npm http 304 https://registry.npmjs.org/cryptiles npm http 304 https://registry.npmjs.org/ctype/0.5.2 npm http 304 https://registry.npmjs.org/combined-stream npm http GET https://registry.npmjs.org/delayed-stream/0.0.5 npm http 304 https://registry.npmjs.org/sntp npm http 304 https://registry.npmjs.org/boom npm http 304 https://registry.npmjs.org/delayed-stream/0.0.5 并完成以下列表: /usr/local/bin/lessc -> /usr/local/lib/node_modules/less/bin/lessc less@1.7.0 /usr/local/lib/node_modules/less ├── mime@1.2.11 ├── mkdirp@0.3.5 ├── source-map@0.1.33 (amdefine@0.1.0) ├── clean-css@2.1.8 (commander@2.1.0) └── […]

如何less用“var less = require('less');”

在那里有人使用“less”这样的: var less = require('less'); less.render('.class { width: (1 + 1) }', function (e, css) { console.log(css); }); 在我的电脑里,它说:“错误:无法find模块'less'”,但是我试图安装“less” "npm install less -g" 在使用之前“require('less');”

用Chrome开发人员工具debuggingLESS

我的目录结构如下: css/style.css style.css.map less/style.less index.html 我创build了一个简单的index.html文件,如下所示: <head> <link type="text/css" rel="stylesheet" media="all" href="css/style.css"> </head> <body> <div id='box'></div> </body> 风格如下: @bgcolor: green; #box { width: 200px; height:200px; background: @bgcolor; } 在css文件夹中,使用下面的命令在style.js命令提示符下将style.css文件从style.less编译为style.css和style.css.map: lessc less/style.less > css/style.css –source-map=css/style.css.map –source-map-basepath=css 然后,我安装了较less的中间件: npm install less-middleware 我试图找出为什么我不能直接在Chrome上debugging较less,因为我已经在Chrome开发工具上启用CSS源地图。 谢谢。

less-middleware不产生输出css

我有以下文件夹结构和较less的文件编译使用less-middleware。 但它不工作。 我尝试了所有我在Google上find的教程。 任何人plz的帮助。 app.use(lessMiddleware(__dirname + '/public/less')); 文件夹结构是 – public/app.css (where would like to get the output) //source folders are. public/less/layout.less, master.less 我在这里做错了什么?

DietJS:回应特定的回应代码

阅读DietJS所有教程: Diet.js | 教程 ,我无法find一种方式来响应一个特定的响应代码。 在信号部分,提到我们可以使用: $.failure(); 我们可以通过以下方式提供有关失败的更多信息: $.error("username", "missing"); 但是默认情况下它的响应代码是200。 有没有直接的指针设置所需的响应代码。