Tag: PowerShell的

“永远”的node.js安装,但不再工作

一两天前,我用npm安装了“ forever ”包,并且永远CLI按预期工作。 然而,今天当我试图永远使用(使用命令forever start app.js ),它给了以下错误消息(格式化我的): forever : The term 'forever' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. 我已经尝试过永久重新安装,npm / node.js和Visual Studio Code(我当前的IDE /文本编辑器),但是这些都不起作用。 也没有重新启动我的电脑。 […]

为什么Node.js会忽略我的PowerShell ExecutionPolicy设置?

我有一个Node.js应用程序,我试图调用PowerShell : var app = require('express')(), child_process = require('child_process'); app.post('/deploy', function(req, res) { var errors = ''; var child = child_process.spawn('powershell.exe', ['deploy.ps1']); child.stderr.on('data', function(data) { errors += data; }); child.stderr.on('end', function() { if (errors) { console.log('Error:'); console.log(errors); } }) child.on('exit', function(code) { console.log('Powershell Script finished'); if (!!code) console.log('I think it failed'); else console.log('I think it […]

如何在Windows上的package.json中的脚本中重新创build文件夹

目标是删除公用文件夹,然后在构build应用程序之前重新创build它。 如果文件夹不存在,这也应该工作。 我在package.json中有这个脚本: "scripts": { "prebuild": "rm -rf public && mkdir public" } 它在Mac和Linux上很好地工作 我怎么能得到它在Windows上,最好在PowerShell中工作?

跨平台的方式获取目录列表,并在其中运行npm install

我正在运行下一个命令为模块目录中的每个模块执行npm install if (process.platform === 'win32') { return 'powershell -noprofile -command "Get-ChildItem ../modules | ? { $_.PSIsContainer } | % { Push-Location $_.FullName; npm install; Pop-Location }"'; } else { return 'for dir in ../modules/*; do (cd $dir && pwd && npm install); done' } 有没有更好的方法来做到这一点? 应该是跨平台的

安装gulp-sass时出现NPM警告:“cross-spawn-async@2.2.4…”

当通过PowerShell安装gulp-sass时,我看到了一个N​​PM警告,我正在尝试理解。 我在PowerShell中inputnpm install gulp-sass ,虽然看起来安装很成功,但我在开始的时候看到了这个警告: npm WARN弃用crossspawn-async@2.2.4:交叉衍生不再需要构build工具链,而是使用它! 我想了解这个警告的含义,以及我应该怎么做。 我应该用什么“它”而不是“什么”?

async.parallel为PowerShell?

在node.js中,我已经非常习惯于使用async.parallel发送多个作业,然后将它们放回到callback中的一个很好的results[]数组中。 在PowerShell中没有任何方法可以做到这一点吗? 我发现的最接近的东西是在循环内使用Start-Job来启动一堆进程; 但是之后我必须使用Receive-Job来获得所有的结果。 不会有像循环之后运行Job-Wait ,然后运行@results = Receive-All-Jobs或类似的东西?

在PowerShell中,使用echo命令编写的文件不能与NodeJS一起使用

echo "console.log('Test success!')" > app.js node app 在Linux上运行良好。 PowerShell,但是,会产生以下错误消息: ~\apps\test\app.js:1 (function (exports, require, module, __filename, __dirname) { c ^ SyntaxError: Invalid or unexpected token at Object.exports.runInThisContext (vm.js:76:16) at Module._compile (module.js:528:28) at Object.Module._extensions..js (module.js:565:10) at Module.load (module.js:473:32) at tryModuleLoad (module.js:432:12) at Function.Module._load (module.js:424:3) at Module.runMain (module.js:590:10) at run (bootstrap_node.js:394:7) at startup (bootstrap_node.js:149:9) at bootstrap_node.js:509:3 另一方面,如果我要echo > […]

我可以在Powershell的PATH中包含一个相对于当前目录的文件夹吗?

我运行了大量的节点项目,并且通常有二进制文件位于: .\node_modules\.bin …相对于项目文件夹。 我希望能够让PATH总是包含这些目录,如果它们存在的话。 我不想包含其他目录,只是相对于当前目录的目录。 我熟悉PSCX和其他Powershell基础知识中的Add-PathVariable ,但是如何在PATH中包含一个相对于当前目录的文件夹? 编辑 :正如问题中所提到的, 我希望path保持更新为目录更改 。 这不是简单地问如何使用pwd 。

性能:System.Diagnostics.Process vs System.Management.Automation.PowerShell

在PowerShell Team的这篇博文中 ,他们专注于posh命令。 有没有办法在不加载任何PS命令的情况下调用Create() ,使它像一个系统进程执行器( System.Diagnostics.Process替代)一样工作? 我们将如何使用System.Management.Automation.PowerShell执行以下操作: node.exe some_module input_file_path –switch1 –switch2=value2 如果1是可能的,下一个问题; 这将执行比Diagnostics.Process.Start()更快? 有没有办法保持在交互模式(在后台线程)调用PS的实例,以交互模式运行node.exe监听来自IRemoteSource的调用? 相反; 调用 , 执行命令并closures每个调用。 这是交互模式的方式,是否会提升性能(由于IRemoteSource调用频繁的大块node.js命令)?

术语“节点”不被识别…在PowerShell中

我一直在试图解决这个问题一整天。 当我在cmd提示符下运行node -v或npm install时,它工作得很好。 但是当我在Powershell中运行相同的命令时,会出现以下错误:s PS C:\Users\Anubhav.Trivedi> node -v The term 'node' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelli ng of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:5 + node <<<< […]