简体   繁体   English

Ansible 无法运行全局 npm 包

[英]Ansible cannot run global npm package

When executing the following scripts where 'bappo-migrate' is a global npm package:执行以下脚本时,其中 'bappo-migrate' 是一个全局 npm 包:

- name: Install migration-cli globally
  npm:
    name: '@bappo/migration-cli'
    global: yes

- name: Run new migration scripts
  command: bappo-migrate upgrade chdir={{homeDir}}/bappo/bappo-api/mongo_migrations
  environment:
    PATH: '{{homeDir}}/.npm-global/bin:$PATH'

Ansible throws error: Ansible 抛出错误:

{  
   "changed":false,
   "cmd":"bappo-migrate upgrade",
   "msg":"[Errno 2] No such file or directory",
   "rc":2
}

Cannot understand the error message - can confirm the directory exists and have tried manually executing the above commands, everything works fine.无法理解错误消息 - 可以确认目录存在并尝试手动执行上述命令,一切正常。

Environment setting should be:环境设置应该是:

environment:
    PATH: "{{ ansible_env.PATH }}:{{homeDir}}/.npm-global/bin"

As ansible can't deal with $PATH in environment correctly.由于 ansible 无法正确处理environment $PATH

Here is Source .这是Source

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM