试图创build一个全局的npm模块。 当执行我的命令我得到“系统找不到指定的path”

我想转换一个我创build的全局使用的npm模块。 https://github.com/toymachiner62/node-mongo-seeds/tree/global 当我运行$ seed ,它给出了错误The system cannot find the path specified所以它知道这是一个全局命令。 我不知道从哪里开始debugging。 我有我的脚本console.logs和他们都没有射击,所以问题在别处,但我不知道接下来要尝试什么。 build议吗? 编辑 我现在在我的Mac上,我把种子节点的shebangpath改为#!/usr/local/bin node 。 尝试使用我的模块时,仍然出现这些错误: $ seed -bash: /usr/local/bin/seed: /usr/local/bin: bad interpreter: Permission denied $ sudo seed sudo: unable to execute /usr/local/bin/seed: Permission denied 编辑 看来这只是我的一个电脑上的一个问题。 另一个工作得很好..

“错误:找不到模块'pkginfo'” – 节点js应用程序部署到heroku

尝试第一次将我的node.js应用程序部署到Heroku时出现以下错误: 应用程序使用“生产”环境configuration2014-08-28T01:02:56.823904 + 00:00 app [web.1]:在Function.Module._resolveFilename(module.js:338:15)2014-08-28T01: 02:56.823906 + 00:00 app [web.1]:at Function.Module._load(module.js:280:25)2014-08-28T01:02:56.823900 + 00:00 app [web.1]:Error :找不到模块'pkginfo'2014-08-28T01:02:56.817349 + 00:00 app [web.1]:^ 2014-08-28T01:02:56.823915 + 00:00 app [web.1]:at Object .module._extensions..js(module.js:474:10)2014-08-28T01:02:56.823908 + 00:00 app [web.1]:at Module.require(module.js:364:17)2014 -08-28T01:02:56.823910 + 00:00 app [web.1]:at require(module.js:380:17)2014-08-28T01:02:56.823912 + 00:00 app [web.1]:在对象。 (/app/node_modules/passport-google-oauth/node_modules/passport-oauth/node_modules/passport/lib/passport/index.js:440:1)2014-08-28T01:02:56.823913 + 00:00 app [web (module.js:456:26)2014-08-28T01:02:56.823918 + 00:00 app [web.1]:at Function.Module._load(module.js:312: 12)2014-08-28T01:02:56.814921 […]

如何处理内部服务器API和HTTP API之间的错误

这就是我的node.js服务器的组织方式 问题 :API通过模型(mongoose)向我的mongodb数据库发出请求。 所以在API层我可以有: User.findById(id, function(user) { if(user._id !== userid) return deferred.reject(new Error()); // ?? if(!user) return deferred.reject(new Error()); // ?? user[field] = value; user.save(function() { deferred.resolve(user); }); }); 但是,我应该抛出什么错误? 什么方法更合适,更方便用户。 我可以尝试例如: if(user._id !== userid) return deferred.reject(new Error(403)); 但是这意味着没有消息,只是错误代码:/ 另一个解决scheme exports.errors = errors = NOT_FOUND: id: "NOT_FOUND" code: 404 message: "Can't found requested object. Please […]

grunt ngtemplates任务100%cpu

咕噜任务ngtemplates运行无限期(近一个小时,没有完成)与100%的CPU利用率。 如果我评论这个任务,那么构build完成。 然后在ngtemplates中创build任务,并在另一台机器上完成OK。 任何想法/线索都非常感谢。 节点版本:0.10.29 grunt-cli:v0.1.13 grunt:v0.4.5 ngtemplates: { app: { cwd: '<%= yeoman.app %>', src: ['views/{,*/}*.html', 'views/inbox/{,*/}*.html' , 'scripts/directives/*.html'], dest: 'scripts/templates.js', options: { usemin: 'scripts/scripts.js', // <~~ This came from the <!– build:js –> block htmlmin: { collapseBooleanAttributes: true, collapseWhitespace: true, removeAttributeQuotes: true, removeComments: true, // Only if you don't use comment directives! removeEmptyAttributes: […]

巨大的文件大小,当浏览angular度

我只是尝试吞噬+angular度+浏览器的应用程序,并得到了一个巨大的浏览文件,大约2M。 尽pipe它只需要angular度和样本控制器。 // setup gulp task gulp.task('browserify', function() { gulp.src([util.format('%s/app/main.js', JS_BASE_DIR)]) .pipe(browserify({ insertGlobals: true, debug: true })) // Bundle to a single file .pipe(concat('bundle.js')) // Output it to our dist folder .pipe(gulp.dest(util.format('%s/js/', BUILD_BASE_DIR))); }); //in the main.js (function() { 'use strict'; var angular = require('angular'); var indexCtrl = require('./controllers/indexCtrl'); var app = angular.module('wohu.app', []); app.controller('ctrl', […]

Mongoose Aggregate:限制$ group中的logging数

我正在尝试使用Mongoose Aggregate方法来转换这个句子: “对于每个玩家的oid,请select最有效的游戏”。 这是我的游戏架构: gameSchema = new mongoose.Schema({ game_name:{type:String}, game_id:{type:String}, oid:{type: String}, number_plays:{type:Number,default:0}, }) Game = mongoose.model('Game', gameSchema); 这是我正在使用的代码: var allids = ['xxxxx','yyyy']; Game.aggregate([ {$match: {'oid': {$in:allids}}}, {$sort: {'number_plays': -1}}, {$group: { _id: '$oid', plays:{$push:"$number_plays"}, instructions:{$push:"$game_instructions"} }} ], function(err,list){ console.log(list); res.end(); }); 上面的代码返回以下内容: [ { _id: 'yyyy', plays: [ 10,4,5 ] }, { _id: 'xxxxx', […]

如何使用passport-google-oauth成功validation后redirect到原始页面

我正在使用node passport-google-oauth模块,并尝试使用基于会话build议的Node.js Passport的Google策略中的自定义returnUrl成功进行身份validation后,将页面redirect回原始path。 但是,我发现在我的callback中,存储在会话中的redirect信息总是被删除,所以我被迫redirect到默认值(在这种情况下是“/”)。 这里是我的代码片段的日志输出。 看起来在callback中,returnTo被消灭了。 这是一个护照的devise谷歌oauth? 如果是这样,authentication成功后又怎么能redirect到原来的页面呢? //从输出 Storing url: /newroom in /auth/google, returnTo = /newroom in /auth/google/callback, returnTo = undefined Storing url: /newroom in /auth/google, returnTo = /newroom in /auth/google/callback, returnTo = undefined //代码片段 var express = require('express'), [sic] passport = require('passport'), GoogleStrategy = require('passport-google-oauth').OAuth2Strategy, cookieParser = require('cookie-parser'), expressSession = require('express-session'), bodyParser = […]

Grunt突然停止工作

试着在我的项目上运行Grunt build和Grunt watch,我遇到了以下错误: Fatal Error: Unable to find local grunt. 我确保文件没有被删除。 我试着重新安装Node和Grunt。 文件在那里,重新安装不起作用。 我已经包含了debugging文件以供参考。 有谁知道这个问题可能是什么? 0 info it worked if it ends with ok 1 verbose cli [ 'E:\\Program Files\\nodejs\\\\node.exe', 1 verbose cli 'E:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js', 1 verbose cli 'install' ] 2 info using npm@1.3.24 3 info using node@v0.10.25 4 verbose node symlink E:\Program Files\nodejs\\node.exe 5 […]

切换到Windows后出现node.js错误 – 错误:%1不是有效的Win32应用程序

我从OSX切换到Windows 7.我正在编写一个项目是抛出一个错误,我认为是有关的开关。 下面的第一行是引起错误的行: if (!/not find/i.test(e.message)) { throw e } 错误是: Error: %1 is not a valid Win32 application. 有人可以告诉我如何让这条线在Windows中工作?

nodejs覆盖模块中的一个函数

我试图在一个模块中testing一个函数。 这个函数(我将它称为function_a)在同一个文件中调用一个不同的函数(function_b)。 所以这个模块看起来像这样: //the module file module.exports.function_a = function (){ //does stuff function_b() }; module.exports.function_b = function_b = function () { //more stuff } 我需要用function_b的特定结果来testingfunction_a。 我想从我的testing文件中覆盖function_b,然后从我的testing文件中调用function_a,导致function_a调用这个覆盖函数而不是function_b。 只是一个笔记,我已经尝试过,并成功地从单独的模块重写function,就像这个问题,但这不是我所感兴趣的。 我已经尝试了下面的代码,据我所知,不起作用。 它确实说明了我要去的。 //test file that_module = require("that module") that_module.function_b = function () { …override … } that_module.function_a() //now uses the override function 有没有一个正确的方法来做到这一点?