我尝试在node.js中通过grunt运行监视任务,但它对我不起作用(这是我得到的):
$ grunt watch
warning: Maximum call stack size exceeded Use --force to continue.
Run Code Online (Sandbox Code Playgroud)
这是Gruntfile.js中watch任务的一部分:
watch: {
less: {
files: 'src/less/*.less',
tasks: ['clean', 'recess', 'copy']
},
js: {
files: 'src/js/*.js',
tasks: ['clean', 'jshint', 'concat', 'uglify', 'copy']
},
theme: {
files: 'src/theme/**',
tasks: ['clean', 'recess', 'copy']
},
images: {
files: 'src/images/*',
tasks: ['clean', 'recess', 'copy']
}
}
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('watch', ['watch']);
Run Code Online (Sandbox Code Playgroud) bunyan中的常规(原始)日志如下所示:
$ node myapp.js
{"name":"myapp","hostname":"myhost","pid":34572,"level":30,"msg":"start","time":"2013-01-04T07:47:25.814Z","v":0}
{"name":"myapp","hostname":"myhost","pid":34572,"widget_type":"wuzzle","level":30,"msg":"creating a wuzzle","time":"2013-01-04T07:47:25.815Z","v":0}
Run Code Online (Sandbox Code Playgroud)
可以使用CLI通过管道日志来使用"短"输出模式 bunyan -o short
$ node myapp.js | bunyan -o short
07:46:42.707Z INFO myapp: start
07:46:42.709Z INFO myapp: creating a wuzzle (widget_type=wuzzle)
Run Code Online (Sandbox Code Playgroud)
默认情况下是否可以使用"短"模式,因此node myapp.js会产生短版本的日志?
我做了一些研究,找不到任何让我的案子成功的东西.
所以,我.js从外部脚本加载require(..),每个脚本导出一个函数..
main.js
var main=10;
var mod1 = require("./mod1.js");
Run Code Online (Sandbox Code Playgroud)
mod1.js
module.exports=function(){
console.log('loaded');
var net=require('net'); // i don't want it to be able to require certain node.js apis
net.create...;
}
Run Code Online (Sandbox Code Playgroud)
我看到了.json文件声明的一些方法,permissions如果是这样,它会授予对脚本的访问权限.如何在核心node.js apis中实现类似的功能?
我是node.js的新手,并试图学习它.
在这里,我试图访问nodejs中的mySQL数据库.
我有这个使用的安装模块,npm install mysql但我没有得到任何文件夹中的mysql node_modules文件夹.
但是从终端安装mysql模块时我没有收到任何错误.因为这个问题我无法在程序中使用mysql模块而且我收到错误
module.js:340
throw err;
^
Error: Cannot find module 'mysql'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/opt/lampp/htdocs/1nodeapp/mysql.js:4:12)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
Run Code Online (Sandbox Code Playgroud) 我正在使用DynamoDB使用以下命令查询表
QueryRequest request = new QueryRequest
{
TableName = "Events",
ExclusiveStartKey = startKey,
KeyConditions = keyConditions,
IndexName = "Title-index" // Specify the index to query against
};
// Issue request
QueryResponse result = client.Query(request);
Run Code Online (Sandbox Code Playgroud)
ExclusiveStartKey和Keyconditions是预定义的
问题是QueryResult结果变量没有解析为我的本机对象,当我使用DynamoDB.Context时,你使用期望的类型转换方法,但在这种情况下我需要解析QueryResult ...还有其他方法去做这个?或者我应该解析对象?
我有在 Moongose 中编写静态函数的经验,例如
var mongoose =require('mongoose');
var Schema = mongoose.Schema;
var adminSchema = new Schema({
fullname : String,
number : Number,
email: String,
auth : {
username: String,
password : String,
salt: String
}
});
adminSchema.statics.usernameInUse = function (username, callback) {
this.findOne({ 'auth.username' : username }, function (err, doc) {
if (err) callback(err);
else if (doc) callback(null, true);
else callback(null, false);
});
};
Run Code Online (Sandbox Code Playgroud)
这里的 usernameInUse 是我想写的函数,但对 mysql 数据库使用sequelize
我的模特
/*
This module is attendant_user table model.
It will store attendants …Run Code Online (Sandbox Code Playgroud)