Tag: batch file

如何在Windows和Unix上运行npm sh脚本

我想运行一个sh脚本,通过npm scripts来检测我的npm版本。 我有以下脚本,它很酷: if [ $(npm -v | cut -c 1 | awk '{print $1\"<3\"}' | bc -l) != 0 ]; then echo '[ERROR] You need npm version @>=3\n' && false; fi 但是,当我在Windows上运行脚本时,这个脚本只能在* NIX上工作我得到一个错误: $(npm was unexpected at this time. 我想检测,如果我在Windows上运行的脚本,然后不执行脚本,我试过,但只能在* NIX: if [ 'uname -s' != CYGWIN* ]; then if [ $(npm -v | […]

自动化一个node.js构build

我正在使用visual studio来pipe理我的应用程序的代码, visual studio online作为git存储库,以及node.js来发布UI。 目前,当我想要发布UI的更新时,我必须打开node.js command prompt并input以下命令: d:更换驱动器 cd: d:\gits\application\application.ui更改为本地应用程序目录 grunt build:angular:beta发布缩小的应用程序 虽然步骤很简单,但要做到这一点还需要一个更快的方法。 有没有办法创build一个脚本来自动执行这些步骤? 请原谅我,如果这个问题有一个看似明显的答案。 这是我使用node.js发布的第一个项目,并且不熟悉这个工具。 我甚至不知道在networkingsearch中使用什么术语。 到目前为止,我find的东西甚至让我接近我想要的东西。 任何build议或想法如何做到这一点?

使用batch file安装多个节点模块

我正在尝试编写一个batch file,它将从不同目录中安装节点模块。 我的问题是脚本导航到foo目录并执行npm install,但是它不会执行其他两个do()命令。 do( cd foo npm install ) do( cd ../bar npm install ) do( cd ../again bower install ) 编辑: 我也尝试了.bat文件中的以下内容 call Install_Node_Components_Site.bat call Install_Bower_Components.bat call Install_Node_Components_Test.bat Install_Node_Components_Site.bat文件是非常基本的,看起来像这样。 cd foo npm install foo目录有packages.json文件,所以我的想法是,我可以像通常从命令行那样调用npm install。

在Node Webkit中使用HTML代码执行.exe或.bat文件

我正在使用节点Webkit,我想有一个HTML文件执行本地文件如.exe或.bat ,而不是下载它。 我试图在HTML文件(index.html)中使用它: <a href="installer/setup.exe" >setup</a> 但它不起作用。

使用VB.NET在file.bat中执行gulp时没有任何反应

我尝试使用VB.NET在file.bat中执行gulpfile.js; 但是,当我debugging或运行file.bat时,没有任何反应(没有错误,没有警告)。 它只适用于双击file.bat后。 这是我的gulpfile.js var gulp = require('D:/Projects/NailsuperStore_Responsive/node_modules/gulp'); var minifyCss = require('D:/Projects/NailsuperStore_Responsive/node_modules/gulp-minify-css'); var uglify = require('D:/Projects/NailsuperStore_Responsive/node_modules/gulp-uglify'); gulp.task('default',['minify-css', 'minify-js']); gulp.task('minify-css', function(){ return gulp.src('../../theme/css/*.css') .pipe(minifyCss({compatility: 'ie8'})) .pipe(gulp.dest('../../theme/css')); }); gulp.task('minify-js', function(){ return gulp.src('../*.js') .pipe(uglify()) .pipe(gulp.dest('../')); }); 我minifyCSS_JS.bat: d: cd D:\Projects\NailsuperStore_Responsive\Website\includes\scripts\nodeJS gulp PAUSE 最后,VB.NET: Dim psi As New ProcessStartInfo("D:\Projects\NailsuperStore_Responsive\Website\Bin\minifyCSS_JS.bat") psi.RedirectStandardError = True psi.RedirectStandardOutput = True psi.CreateNoWindow = False psi.WindowStyle […]

Node.js作为服务,exec不起作用

我使用nssm作为服务运行Node.js项目。 当用户点击我的nodejs网站上的button时,它应该运行require('child_process').exec('cmd /c batfile.bat', function({ res.send(somedata); });而是跳过正在运行的bat文件并跳转到res.send(somedata) 。为什么是这样的?当我运行Node.js使用cmd和npm start server.js它工作正常。如何使exec执行工作,同时运行nodejs作为服务? 编辑一些代码: require('child_process').exec('cmd /c batfile.bat', function(){ var log = fs.readFileSync('logs/batlog.log', 'utf8'); var html = fs.readFileSync('logs/batlog.htm', 'utf8'); var json = {"log": log, "html": html}; res.send(json); }); batfile.bat应该生成这两个文件,但是如果我将nodejs作为服务运行,则不会。

Inno Setup – 由安装程序添加到PATH中的npm程序无法在从安装程序执行的batch file中识别

我已经创build了一个Windows安装程序使用Inno安装程序为我所做的应用程序。 作为安装程序的一部分,我已经安装了一些第三方应用程序,后面跟着一个batch file,执行一些npm命令可操作的程序或batch file。 一切安装好,但batch file运行时,我得到的消息 “npm”不被识别为内部或外部命令 命令不运行,所以应用程序不会打开。 但是,如果我保持原样,只需在安装后重新运行batch file,命令就会执行并且应用程序正常工作。 如何让batch file作为安装的一部分正确运行? Inno Setup Run部分 [Run] Filename: "{tmp}\Git-2.15.0-64-bit.exe"; Flags: waituntilterminated Filename: "{tmp}\rubyinstaller-2.3.3-x64.exe"; Flags: waituntilterminated Filename: "{tmp}\visualcppbuildtools_full.exe"; Flags: waituntilterminated Filename: "msiexec.exe"; Parameters: "/i ""{tmp}\mongodb-win32-x86_64-2008plus-ssl-3.4.10-signed.msi"; WorkingDir: {tmp}; Flags: waituntilterminated Filename: "msiexec.exe"; Parameters: "/i ""{tmp}\node-v6.11.0-x64.msi"; WorkingDir: {tmp}; Flags: waituntilterminated Filename: "{tmp}\setup.bat"; Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: […]

量angular器不能正常工作的端到端testing

我是runnungangular度种子项目(代码位于这里 ),我安装了Node.js,茉莉花(与C:\Users\nradisic\Documents\Visual Studio 2013\WebSites\angular-seed-master>npm install jasmine )和量angular器(使用C:\Users\nradisic\Documents\Visual Studio 2013\WebSites\angular-seed-master>npm install protractor )。 我试图用runnung e2e-test.bat与内容运行量angular器的端到端testing: @echo off REM Windows script for running e2e tests REM You have to run server first REM REM Requirements: REM – NodeJS (http://nodejs.org/) REM – Protractor (npm install -g protractor) set BASE_DIR=%~dp0 webdriver-manager update protractor "%BASE_DIR%\..\config\protractor-conf.js" %* 和protractor-conf.js: exports.config = { […]

自动启动和停止node.js脚本

我想运行这个节点。 js脚本不使用命令提示符: var spawn = require('child_process').spawn; // Run node with the GenerateBlob.js file as an argument var child = spawn('node', ['GenerateBlob.js']); // Listen for any response from the child: child.stdout.on('data', function (data) { var result = data.toString(); }); // Listen for any errors: child.stderr.on('data', function (data) { console.log('There was an error: ' + data); }); […]

在bat文件中查询npm错误状态

我们正在将我们的UI项目(共3个)构build到Grunt。 为了简化转换,我想提供一个bat文件,它将为每个项目运行npm install ,但是我想知道在发出这个命令时是否出现了问题。 我之后只是糖衣,我知道npm会回应错误,但是我希望我的团队中不熟悉npm和node的成员能够更轻松地发送消息。 有没有办法检查npm是否遇到错误,并随后停止bat文件? 例如,如果节点没有安装,我只是检查%ERRORLEVEL%是1.如果是这种情况,我回显一些指令并退出执行。 我遇到的问题是,在npm install过程中发生错误时, %ERRORLEVEL%未设置为1。 任何帮助感激!