如何使用 Ansible 运行 全局 npm 二进制文件
How to run global npm binaries with Ansible
- 我已将我的 npm 全局安装路径设置为
npm config set prefix '~/.npm-packages
- 我已经更新我的 PATH 以包含它。在
~/.profile
我有 PATH="$HOME/.npm-packages/bin:$PATH"
- 我已经用
npm install -g gulp
安装了 gulp,验证它存在于 ~/.npm-packages/bin/gulp
- 我已经通过 SSH 连接到我的远程机器并输入
gulp
验证了它在我的 PATH 中并且可以执行
我正在使用以下 Ansible 任务:
name: Run gulp
command: gulp
args:
chdir: app/
但它总是会出现以下错误:
{"cmd": "gulp", "failed": true, "rc": 2}
msg: [Errno 2] No such file or directory
为什么我可以 运行 gulp
从 SSH 会话而不是通过 Ansible?
我终于能够通过以下方式做到这一点。
- name: Run gulp
command: ~/.npm-packages/bin/gulp
args:
chdir: app/
- 我已将我的 npm 全局安装路径设置为
npm config set prefix '~/.npm-packages
- 我已经更新我的 PATH 以包含它。在
~/.profile
我有PATH="$HOME/.npm-packages/bin:$PATH"
- 我已经用
npm install -g gulp
安装了 gulp,验证它存在于~/.npm-packages/bin/gulp
- 我已经通过 SSH 连接到我的远程机器并输入
gulp
验证了它在我的 PATH 中并且可以执行
我正在使用以下 Ansible 任务:
name: Run gulp
command: gulp
args:
chdir: app/
但它总是会出现以下错误:
{"cmd": "gulp", "failed": true, "rc": 2}
msg: [Errno 2] No such file or directory
为什么我可以 运行 gulp
从 SSH 会话而不是通过 Ansible?
我终于能够通过以下方式做到这一点。
- name: Run gulp
command: ~/.npm-packages/bin/gulp
args:
chdir: app/