"No such file or directory" 当来自 NPM 脚本的 运行 命令时
"No such file or directory" when running command from NPM script
我想在我的 NPM 脚本中使用一个简单的命令。
命令是:
cat ./path/**/*.css > ./other/path/plugins.css
如果我 运行 在我的终端中使用它,它就可以工作。
但是,如果我把它放在 NPM 脚本中,就像这样:
"scripts" {
"cat": "cat ./path/**/*.css > ./other/path/plugins.css"
}
我会得到没有这样的文件或目录。
知道可能是什么原因吗?
谢谢!
它不起作用的原因是因为 cat 接受文件名作为参数并且星号 (glob) 被您的 shell(很可能是 bash)转换为文件名。
它不能与 npm 脚本一起工作的原因是因为它不是 shell 中的 运行,它支持您要使用的功能(glob 扩展,stdout 重定向到文件) .
要解决它,只需运行它在bash的实例中:
"scripts" {
"cat": "bash -c 'cat ./path/**/*.css > ./other/path/plugins.css'"
}
我想在我的 NPM 脚本中使用一个简单的命令。 命令是:
cat ./path/**/*.css > ./other/path/plugins.css
如果我 运行 在我的终端中使用它,它就可以工作。 但是,如果我把它放在 NPM 脚本中,就像这样:
"scripts" {
"cat": "cat ./path/**/*.css > ./other/path/plugins.css"
}
我会得到没有这样的文件或目录。
知道可能是什么原因吗?
谢谢!
它不起作用的原因是因为 cat 接受文件名作为参数并且星号 (glob) 被您的 shell(很可能是 bash)转换为文件名。
它不能与 npm 脚本一起工作的原因是因为它不是 shell 中的 运行,它支持您要使用的功能(glob 扩展,stdout 重定向到文件) .
要解决它,只需运行它在bash的实例中:
"scripts" {
"cat": "bash -c 'cat ./path/**/*.css > ./other/path/plugins.css'"
}