css - Npm 多文件脚本 (lessc)

标签 css node.js powershell less

我正在尝试在我的 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/

相关文章:

powershell - Powershell v .bat Call在Soundplayer上有区别吗?

html - BootStrap 3 构建主页面

javascript - A帧图像亮度

node.js - puppeteer overridePermissions 剪贴板读取不适用于 createIncognitoBrowserContext()

java - 在 Node js 中通过 AES/GCM/NoPadding 算法使用 key 和 iv 加密有效负载并在 java 中解密

string - 无法将 'System.Object[]'转换为 'System.String'类型

powershell - 将 7-zip 参数作为变量插入

html - CSS Filter Multiple URL - 同时获得模糊和灰度

html - CSS/表格 : parallel two columns for different languages?

mysql - 捕获/处理 MySQL 重复条目错误 - 使用 Node JS、Passport JS、Express、connect-flash、Heroku