Tag: macos

NodeJS fs.watch on目录只在被编辑器更改时触发,而不是shell或fs模块

当下面的代码运行时,只有手动编辑和保存tmp.txt才能触发监视,使用我的ide,TextEditor.app或vim。 它不通过写入stream或手动shell输出redirect的方法(键入echo“test”> /path/to/tmp.txt“)。 虽然如果我看文件本身,而不是它的dirname,那么它的作品。 var fs, Path, file, watchPath, w; fs = require('fs' ); Path = require('path'); file = __dirname + '/tmp.txt'; watchPath = Path.dirname(file); // changing this to just file makes it trigger w = fs.watch ( watchPath, function (e,f) { console.log("will not get here by itself"); w.close(); }); fs.writeFileSync(file,"test","utf-8"); fs.createWriteStream(file, { flags:'w', mode: […]

无法从本地networking上的不同设备访问Mac上的节点服务器

我使用OS X 10.9在我的Mac上运行节点服务器。这里是代码 var http = require('http'); http.createServer(function (request, response) { response.writeHead(200, {'Content-Type': 'text/plain'}); response.end('Hello World\n'); }).listen(3000, '0.0.0.0'); console.log('Server running at http://192.168.1.120:3000/'); 我可以在我的Mac上使用Safari访问http://192.168.1.120:3000/服务器。 但是,当我用我的iPhone访问服务器,它失败了。 我的Mac的防火墙closures了,我的iPhone和Mac一样都在同一个WiFi上。

bcrypt不能用npm安装(Mac OS X 10.9 – Node v0.10.22)

系统规格:Mac OS X 10.9节点v0.10.22 尝试安装bcrypt时出现以下错误。 任何关于如何解决这个问题的build议? 任何帮助将不胜感激。 > bcrypt@0.7.6 install /Users/eDawg/Desktop/eggstage/node_modules/bcrypt > node-gyp rebuild CXX(target) Release/obj.target/bcrypt_lib/src/blowfish.o ../src/blowfish.cc:47:10: fatal error: 'sys/types.h' file not found #include <sys/types.h> ^ 1 error generated. make: *** [Release/obj.target/bcrypt_lib/src/blowfish.o] Error 1 gyp ERR! build error gyp ERR! stack Error: `make` failed with exit code: 2 gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23) gyp […]

Node-webkit通知声音

我为node-webkit应用程序做了一个函数来触发OS X通知。 它完美的作品,但我不知道是否可以设置一个系统或自定义的声音,而不是经典的iPhone Boing的声音? 我查阅了Mozzila的官方通知API文档( https://developer.mozilla.org/en-US/docs/Web/API/notification ),没有声音选项,但是也许node-webkit植入了该function(无法想象他们没有),但如果他们这样做,我似乎无法find任何文件。 所以我的问题是,在node-webkit中有通知的声音吗? function notif(title ,tekst, url){ var notice = new Notification(title, { body: tekst }); notice.onshow = function(evt) { setTimeout(function(){notice.close()}, 5000); } notice.onclick = function(evt) { gui.Shell.openExternal(url); setTimeout(function(){notice.close()}, 1000); }; }

节点已经安装,只是没有链接

我试图修复错误,在运行npm时必须使用sudo。 我盲目地遵循一个链接卸载节点,代码是从这个要点 运行该命令后,我试图用brew: brew install node安装它。 这给了我以下错误: Error: The `brew link` step did not complete successfully The formula built, but is not symlinked into /usr/local Could not symlink share/doc/node/gdbinit /usr/local/share/doc/node is not writable. You can try again using: brew link node 尝试运行brew link node ,我得到: Linking /usr/local/Cellar/node/5.4.0… Error: Could not symlink share/systemtap/tapset/node.stp /usr/local/share/systemtap/tapset is not […]

如何安装Grunt

我用Homebrew来安装Node.js,然后使用npm install来安装Grunt及其依赖项,但安装完成后,我无法运行Grunt: zsh: correct 'grunt' to 'grn' ÆnyaeÅ? n zsh: command not found: grunt 什么是安装Grunt的正确方法,所以我不会得到这个错误?

Mac npm与ENOENT错误

我是最近从Windows转换到Mac,目前只是试图让我的工具设置。 我首先安装节点使用自制软件,这是给我错误(相同的,我还有)。 我后来使用自制软件删除节点,并使用节点网站上的pkg进行安装。 我可以在命令行和npm中访问节点。 问题是当我尝试在本地项目上安装模块时,我得到如下所示的内容: npm install grunt-contrib Error extracting archive { [Error: ENOENT, open '/Users/davidmckeown/dev/adt-com/node_modules/grunt-contrib/node_modules/grunt-contrib-qunit/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/tmp/phantomjs-1.7.0-macosx.zip'] errno: 34, code: 'ENOENT', path: '/Users/davidmckeown/dev/adt-com/node_modules/grunt-contrib/node_modules/grunt-contrib-qunit/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/tmp/phantomjs-1.7.0-macosx.zip' } 在上面的另一个消息包含: npm ERR! phantomjs@0.2.6 install: `node install.js` npm ERR! `sh "-c" "node install.js"` failed with 8 npm ERR! npm ERR! Failed at the phantomjs@0.2.6 install script. npm ERR! This is most likely […]

打开来自node –inspect命令的标准输出

好吧,这里有一个有趣的,我们得到以下stdout: Debugger listening on port 9229. Warning: This is an experimental feature and could change at any time. To start debugging, open the following URL in Chrome: chrome-devtools://devtools/remote/serve_file/@60cd6e859b9f557d2312f5bf532f6aec5f284980/inspector.html?experiments=true&v8only=true&ws=127.0.0.1:9229/a7a2a58d-dfd1-4cc6-875c-47da78adeb1b 当我们像这样运行一个命令: node –inspect –debug-brk bin/www.js 我正在考虑创build一个这样的bash脚本: #!/usr/bin/env bash NODE_DEBUG_OUTPUT=$(node –inspect –debug-brk bin/www.js) open -a "/Applications/Google Chrome.app"/ getUrl(${NODE_DEBUG_OUTPUT}) 但这里是我的bash技能结束的地方 – 我如何实现getUrl函数,以便我可以从输出中获取URL? 我非常确定,如果我们将bash传递给open函数,它将打开浏览器,在这种情况下,它必须是Google Chrome浏览器。

使用NSTask来执行离子build立命令 – 启动path不可访问

我正在与具有命令行界面的Ionic合作。 我想创build一个小的Mac应用程序,帮助执行某些命令。 在terminal我cd Users/me/Desktop/Repos/ionic-project/myApp改变后,我会例如ionic run NSTask *task = [[NSTask alloc]init]; task.launchPath = @"/bin/bash"; task.currentDirectoryPath = @"cd Users/me/Desktop/Repos/ionic-tryouts/myApp"; task.arguments = @[@"ionic run"]; [task launch]; 但是这给了我“工作目录不存在”。 我在这里已经阅读了相当多的线索。 我的错误是什么? 编辑: 感谢Christik的详细解答。 我现在有这样的代码: NSTask *task = [[NSTask alloc]init]; task.launchPath = @"/usr/local/bin/ionic"; task.currentDirectoryPath = @"/Users/me/ionic-tryouts/myApp"; task.arguments = @[@"run"]; [task launch]; 现在我得到以下错误:env:node: No such file or directory 。 我想这是来自一个问题,node.js没有find(离子build立在节点的顶部)。 我发现这个问题 – […]

如何使用node-gyp在Mac上生成XCode项目

我正在使用node-gyp来构buildnode.js加载项。 binding.gyp文件的内容是 { 'targets': [ { 'target_name': 'myapp', 'include_dirs': ['api-sdk'], 'sources': [ 'main.cpp', 'lib.cpp'], 'cflags!': [ '-fno-exceptions' ], 'cflags_cc!': [ '-fno-exceptions' ], 'conditions': [ ['OS=="mac"', { 'xcode_settings': { 'GCC_ENABLE_CPP_EXCEPTIONS': 'YES' } }] ] } ] } 在Windows上,当我运行node-gyp configure ,Visual Studio项目会自动生成。 但在Mac上,在执行node-gyp configure gyp configure之后不会生成相应的XCode项目。 有谁知道如何用Node-gyp生成XCode项目? 我应该添加一些设置到binding.gyp文件? 谢谢, 杰弗里