嗨,我正在尝试在Windows 7 64位上安装Grunt.我已经使用命令安装了Grunt
npm install -g grunt
npm install -g grunt-cli
Run Code Online (Sandbox Code Playgroud)
但现在,如果我尝试做grunt init,它会给我一个错误 -
找不到有效的Gruntfile.有关如何配置grunt的更多信息,请参阅入门指南: http://gruntjs.com/getting-started致命错误:无法找到Gruntfile.
但当我查看我系统上的grunt文件夹时,就在Gruntfile.js那里.有人可以指导我如何正确安装这个grunt以及如何使用grunt编写构建的脚本.如果我想使用Grunt构建脚本,我有一个HTML页面和java脚本我该怎么办?
我正在尝试处理发送到我的node.js服务器的post请求.名为server.js的JavaScript文件在浏览器上显示一个表单.我希望在将表单值发布到node.js后端后访问它们.
表单包含用户名,存储库和分支.提交表单时,我想将此数据显示回用户.
server.js代码:
var http = require('http');
http.createServer(function (request, response) {
response.writeHead(200, {'Content-Type': 'text/html'});
response.end('<html><body>'
+ '<h1>XYZ Repository Commit Monitor</h1>'
+ '<form method="post" action="." enctype="application/x-www-form-urlencoded"><fieldset>'
+ '<div><label for="UserName">User Name:</label><input type="text" id="UserName" name="UserName" /></div>'
+ '<div><label for="Repository">Repository:</label><input type="text" id="Repository" name="Repository" /></div>'
+ '<div><label for="Branch">Branch:</label><input type="text" id="Branch" name="Branch" value="master" /></div>'
+ '<div><input id="ListCommits" type="submit" value="List Commits" /></div>'
+ '</fieldset></form>'
+ '</body></html>');
}).listen(8124);
console.log('Server running at http://127.0.0.1:8124/');
Run Code Online (Sandbox Code Playgroud) 我已经尝试了一些Node.js的例子,但我仍然对jQuery和Node.js感到困惑.
此时我所知道的是Node.js和jQuery执行两个不同的角色.一个方便了服务器端JavaScript,另一个提供了客户端JavaScript的抽象库.
我已经在Stack Overflow上看到了一些与Node.js和jQuery相关的其他链接,但是我没有得到我想要的东西.
Node.js的功能差异或特殊之处是什么让我想到它?如果我选择使用Node.js,我会得到什么好处?我知道Node.js适用于事件驱动编程,而不是面向对象的编程语言,但我还能用Node.js做些什么呢?我不能用jQuery或其他框架做什么?
我有几个问题:
可以通过jQuery无法完成的Node.js做什么?
Node.js能否使用Web服务?如果是,那么可以用jQuery做同样的事情吗?如果没有,那么它的原因是什么?
Node.js有哪些功能?它与jQuery有何不同?
我应该在哪种情况下使用Node.js或jQuery?
Node.js和jQuery有哪些特殊功能?使用两者的好处?
我有一个URL" http://localhost:8888/api/rest/abc",它将提供以下json数据.我想使用Jquery或java脚本在我的UI中获取此数据.我是在几个小时内尝试这个,但我无法解决它.请建议我一些解决方案,这将有助于我解决这个问题.
{
"My-user": [
{
"link": [
{
"href": "http://localhost:8888/api/rest/abc/MI/CH",
"rel": "self",
"type": "application/my.My.My-user+xml",
"title": "rln"
},
{
"href": "http://localhost:8888/api/rest/cabin?MI=mi&CH=ch",
"rel": "some relation",
"type": "application/my.My.My-cabin+xml",
"title": "rln1"
}
],
"My-user-list": [
{
"name": "cuba",
"Explanation": "bark"
}
],
"CH": "ch",
"MI": "mi",
"password": "xyz",
},
{
"link": [
{
"href": "http://localhost:8888/api/rest/abc/DD/KN",
"rel": "self",
"type": "application/my.My.My-user+xml",
"title": "rln"
},
{
"href": "http://localhost:8888/api/rest/cabin?DD=dd&KN=kn",
"rel": "some relation",
"type": "application/my.My.My-cabin+xml",
"title": "rln1"
}
],
"My-user-list": [
{
"name": "Cuba1",
"Explanation": "bark1"
} …Run Code Online (Sandbox Code Playgroud) 我想通过身份验证来使用这个rest api.我正在尝试包括标题但没有得到任何回复.它抛出的输出通常在没有认证时抛出.谁能建议我一些解决方案.下面是我的代码
var http = require('http');
var optionsget = {
host : 'localhost', // here only the domain name
port : 1234,
path:'/api/rest/xyz',
headers: {
'Authorization': 'Basic ' + new Buffer('abc'+ ':' + '1234').toString('base64')
} ,
method : 'GET' // do GET
};
console.info('Options prepared:');
console.info(optionsget);
console.info('Do the GET call');
var reqGet = http.request(optionsget, function(res) {
console.log("statusCode: ", res.statusCode);
res.on('data', function(d) {
console.info('GET result:\n');
process.stdout.write(d);
console.info('\n\nCall completed');
});
});
reqGet.end();
reqGet.on('error', function(e) {
console.error(e);
});
Run Code Online (Sandbox Code Playgroud) 嗨,我的tomcat7安装在亚马逊云中的位置/ usr/sbin/tomcat7,我的war文件(xyz.war)位于downloads文件夹中.如何将war文件复制到我的webapps文件夹中.我是Linux的新手,可能这很简单,但我很难用它.请一些人来上面给我一些例子.
提前致谢.
javascript ×3
node.js ×3
jquery ×2
amazon-ec2 ×1
gruntjs ×1
html5 ×1
linux ×1
npm ×1
npm-install ×1
rest ×1
tomcat7 ×1
war ×1