Tag: bash

-bash:grunt:找不到命令

我正在使用节点0.10.35和grunt命令工作正常。 现在升级到0.12.3之后grunt命令已经停止工作。 OS:Mac OSX 10.10.1节点:0.12.3 npm:2.9.1 grunt:0.4.5 我以为在节点安装中可能会有问题,所以我干净地安装了它3-4次 我试着用 – 节点v0.12.3.pkg 节点版本pipe理器(nvm) 针对这些问题的许多解决scheme都build议使用npm install -g grunt-cli 然后使用npm install来安装本地节点模块。 我遵循该程序,但我得到同样的错误。

debugging使用bash文件和nodejs执行的mysql查询

我试图创build一个cron作业插入数据到表中,但它不工作,我甚至找不到一个方法来正确debugging它。 这个想法是相当基本的:获取文件path,发布并执行script.sh文件。 该脚本遍历文件的内容并将其插入到数据库中。 HTMLinput部分非常简单: <form action="http://127.0.0.1:9080/config" method="post"> <input type="text" name="data" style="width: 500px;"> <input type="submit" id="button" value="config"></input> </form> 和server.js处理也是相当基本的(我离开cron实现,因为它正在工作,而不必为我的问题): app.post('/config', function (req, res) { var source = req.body.data; var script = ' /home/al/Downloads/DataMining/node.js/script.sh ' + source; //file not found -> full path of source file exec(script); addCronTab(script); //readFile – response file that read.. res.end(script); }); 我认为这个问题来自我的bash文件: […]

如何在AWS中的NodeJS中编写Mongo Replicas脚本

我有3个服务器都运行Mongo作为副本集,1个主副本和2个副本。 如果一个失败,我的自动比例将杀死实例,并使用用户数据重新启动服务器重新安装软件包。 我怎么能通知主(新的或旧的),实例已经复活,因为它将有一个新的私有IP地址(你不能分配静态私有IP的自动调整/启动configuration) 我似乎无法在Mongoose或Mongo Node Driver的最新版本中find一种方法来告诉主要有一个想要join的新实例。 我可以通过访问Mongo shell并传入来手动执行此操作 rs0:PRIMARY> rs.add("10.23.229.17"); 它将被添加,并且数据将同步。 但是,我怎样才能通过节点驱动程序或Bash脚本rs.add? 更新 我发现这个post非常有用, 我可以使用MongoDb驱动程序从node.js调用rs.initiate()和rs.Add()吗? 基本上, 这是所有数据库命令的列表。 虽然我找不到任何包装好的东西,但使用命令方法很容易: var MongoClient = require('mongodb').MongoClient; MongoClient.connect('mongodb://10.23.223.231', function(err, db) { if (err) { console.log('error', err); } else { var adminDb = db.admin(); //use any command from https://goo.gl/0oh6H5 adminDb.command({ replSetGetConfig: 1 }, function(err, info) { if (!eer) { console.log(info); } […]

Node.js与Git Bash(MINGW64)

我正在运行Windows。 我刚刚用MSI安装程序更新了node.js。 我总是用git bash来运行命令。 但升级之后,git bash中的节点版本没有改变: $ node -v v0.11.14 如果我在cmd下运行,它会显示一个不同的版本: $ node -v v4.3.1 我在git bash中检查了$ PATH,它指向了正确的位置(c:\ Program Files \ nodejs) 可能是什么问题呢?

如何从节点脚本执行时查看bash命令

我有一个节点应用程序,我使用bitbucket中的webhook来触发bash脚本来运行一些命令来部署我的应用程序。 它工作,但是我不能查看任何正在运行的命令(即进度命令echo'd)。 我怎样才能做到这一点? 这是相关的代码: var shellPath = path.join(__dirname + '../../deploy/deploy.sh'); var exec = require('child_process').exec; function puts(error, stdout, stderr) { console.log('stout: ', stdout) console.log('error: ', error) console.log('stderr: ', stderr) } exec(shellPath, puts); deploy.sh – echo Preparing to Git Fetch git reset –hard origin/master echo Preparing to clean git clean -f echo Preparing to pull git pull […]

当pipe道到标准输出时,nodejs fifo工作,但当pipe道到文件时不工作

我正在玩节点和fifos,正在得到一些我无法解释的怪异行为。 基本上,我使用spawn创build一个fifo,创build一个写入到该FIFO的stream,将数据传输到写入stream,并产生一个从fifo读取的cat命令。 如果我然后将cat命令的结果传递给标准输出,但是如果将它们传输到另一个文件则不起作用。 请参阅下面的代码 注意:这种行为只有在写入足够的数据来写入缓冲区时才会出现 var fs = require('fs'), stream = require('stream'); // create read stream var rs = fs.createReadStream('testinput') var spawn = require('child_process').spawn; // create fifo var fifo = spawn('mkfifo', ['testfifo']); fifo.on('exit', function() { // when fifo is created, proceed // create outfile and attach fifostream var ws = fs.createWriteStream('testoutput') var fifows = fs.createWriteStream('testfifo'); […]

用Nodejs改变bashterminal的当前工作目录

我想要开发一个Node CLI应用程序,它可以将git repo和cd复制到其中。 例如。 dummyuser:~$ dummy-cli-command dummy-git-repo-url Cloning repository… dummyuser:~/Workspace/dummy-git-repo$ 我能克隆它,但不能cd进去。 我知道节点分支了一个subprocess,在这个进程下它执行我的代码,并且没有办法改变我首先执行我的node-cli-command的bashterminal的目录。 任何人都可以帮我解决任何问题吗?

运行npm脚本时使用哪个shell npm?

我在通过ConEmu运行鱼壳的Windows上。 鱼默认不承认“&&”运营商, 但是有这样的: "scripts": { "test": "echo 'a' && echo 'b'" } 并运行“npm run test”正在工作。 所以我认为它必须使用默认的“cmd”,这就是npm config ls -l | grep shell 然而, npm config ls -l | grep shell说,当我把“testing”脚本改为: "scripts": { "test": "echo 'a' && ls" } 这也可以工作,而ls显然不支持“cmd”。 这到底是怎么回事? 😲

Selenium:服务器以状态127结束

我看了很多其他的post,似乎没有为我工作,即使它给出了同样的错误。 我通过Windows运行bash,所有我想要做的是从npm selenium-webdrivers获取给定的代码加载,甚至不工作。 这是app.js: require('chromedriver'); const webdriver = require('selenium-webdriver'), By = webdriver.By, until = webdriver.until; var driver = new webdriver.Builder() .forBrowser('chrome') .build(); driver.get('http://www.google.com/ncr'); driver.findElement(By.name('q')).sendKeys('webdriver'); driver.findElement(By.name('btnG')).click(); driver.wait(until.titleIs('webdriver – Google Search'), 1000); driver.quit(); 这里是我运行节点app.js 这里的Bash错误 任何帮助,将不胜感激

无法在Windows上投放angular度项目

我使用节点js,在Windows环境下的angular度cli,我最近克隆了我正在对我的Windows机器的项目,但它不提供以下的erorr,因为项目完全在我的Linux机器上运行,什么可以是可能的原因? ng serve ** NG Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200 ** 12% building modules 22/38 modules 16 active …tend\node_modules\strip-ansi\index.jsError: No module factory available for dependency type: ContextElementDependency at Compilation.addModuleDependencies (node_modules\@angular\cli\node_modules\webpack\lib\Compilation.js:206:21) at Compilation.processModuleDependencies (node_modules\@angular\cli\node_modules\webpack\lib\Compilation.js:195:8) at _this.buildModule.err (node_modules\@angular\cli\node_modules\webpack\lib\Compilation.js:336:13) at building.forEach.cb (node_modules\@angular\cli\node_modules\webpack\lib\Compilation.js:140:27) at Array.forEach (native) at callback (node_modules\@angular\cli\node_modules\webpack\lib\Compilation.js:140:13) at module.build (node_modules\@angular\cli\node_modules\webpack\lib\Compilation.js:167:11) […]