Node.js 如何编写跨平台工作的Npm脚本命令

Node.js 如何编写跨平台工作的Npm脚本命令,node.js,npm,openshift,bower-install,Node.js,Npm,Openshift,Bower Install,我正在尝试编写一个postinstall命令,该命令与openshift配合使用,以安装bower依赖项。我已经设法使它工作,这是伟大的 "scripts": { "postinstall": "HOME=$OPENSHIFT_REPO_DIR bower install" } 我现在正在尝试改进该命令,以便可以在windows PC上本地运行以下命令 npm install 它抛出一个错误: PS D:\dev\cgb14\code\trunk\solution\App> n

我正在尝试编写一个postinstall命令,该命令与openshift配合使用,以安装bower依赖项。我已经设法使它工作,这是伟大的

"scripts": {
    "postinstall": "HOME=$OPENSHIFT_REPO_DIR bower install"
}
我现在正在尝试改进该命令,以便可以在windows PC上本地运行以下命令

npm install
它抛出一个错误:

PS D:\dev\cgb14\code\trunk\solution\App> npm install

> warcher_app@1.0.0 postinstall D:\dev\cgb14\code\trunk\solution\App
> HOME=$OPENSHIFT_REPO_DIR node_modules/.bin/bower install

'HOME' is not recognized as an internal or external command,
operable program or batch file.

npm ERR! Windows_NT 6.3.9600
npm ERR! argv "D:\\Program Files\\nodejs\\\\node.exe" "D:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "ins
tall"
npm ERR! node v0.12.4
npm ERR! npm  v2.10.1
npm ERR! code ELIFECYCLE
npm ERR! warcher_app@1.0.0 postinstall: `HOME=$OPENSHIFT_REPO_DIR node_modules/.bin/bower install`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the warcher_app@1.0.0 postinstall script 'HOME=$OPENSHIFT_REPO_DIR node_modules/.bin/bower install'.
npm ERR! This is most likely a problem with the warcher_app package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     HOME=$OPENSHIFT_REPO_DIR node_modules/.bin/bower install
npm ERR! You can get their info via:
npm ERR!     npm owner ls warcher_app
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     D:\dev\cgb14\code\trunk\solution\App\npm-debug.log
有人知道如何改进postinstall脚本,使其也能在windows上工作吗


我一直在搜索关于npm命令可以执行哪些操作的文档,并查看是否存在跨平台if-exists语句。我在想,如果$OPENSHIFT\u REPO\u DIR存在,应该这样做。。。其他的做一些其他的…

对,在我发布这篇文章5分钟后,我想到了一些我还没有尝试过的东西。命令中的一个简单或简单的命令起作用。我现在可以在Windows和Openshift上运行此功能

"scripts": {
  "postinstall": "HOME=$OPENSHIFT_REPO_DIR bower install || bower install"
}