我正在尝试在我的 package.json
中运行 lessc
PowerShell 命令行。
所以在我的脚本部分我有类似的东西:
Get-ChildItem *.less -Recurse | ForEach-Object {lessc $_.FullName > $_.BaseName.css}
但它给了我以下错误:
'Get-ChildItem' is not recognized as an internal or external command
虽然这在 PowerShell 中正常执行
Get-ChildItem *.less -Recurse | ForEach-Object {echo $_.Name}
一个普通的 lessc
命令也能按预期工作。
有什么想法吗?
Also check this question that have another solution for this.
最佳答案
错误消息表明您没有在 PowerShell 中运行该语句。 lessc
是一个 node.js 应用程序,而不是 PowerShell 命令,因此它在单独使用时可以正常工作也就不足为奇了。
为了能够使用 PowerShell cmdlet,您需要在 PowerShell 中运行语句,例如像这样:
powershell.exe -ExecutionPolicy Bypass -Command "Get-ChildItem *.less -recurse | Foreach-Object{ lessc $_.FullName > $_.BaseName.css }"
关于css - Npm 多文件脚本 (lessc),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34874501/