【问题标题】:How to deploy an Angular App with Capistrano如何使用 Capistrano 部署 Angular 应用程序
【发布时间】:2015-10-15 10:15:34
【问题描述】:

我正在尝试按照 this 教程使用 Capistrano 部署 Angular 应用程序。所以在我的 Capfile 我有以下内容:

require 'capistrano/setup'
require 'capistrano/deploy'
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }

在我的config/deploy 文件中,我有以下内容:

...
task :bower_and_npm_install do 
  on roles(:app), in: :sequence, wait: 5 do
    within release_path do 
      execute :npm, "install"
      execute :bower, "install"
    end
  end
end
after :published, :bower_and_npm_install
...

当我尝试部署时,我收到以下错误:

[6ff53bb3] Command: cd /home/user/apps/myapp/releases/20151015095546 && /usr/bin/env npm install
DEBUG [6ff53bb3]  /usr/bin/env:
DEBUG [6ff53bb3]  npm
DEBUG [6ff53bb3]  : No such file or directory

我尝试了以下方法:

...
execute "bash -c '. /usr/bin/npm && cd #{current_path} && npm install'"
...
OR
execute "/usr/bin/npm && cd #{current_path} && npm install'"
OR
execute "cd #{current_path} && npm install'"

但没有一个奏效。

有什么想法吗?

【问题讨论】:

    标签: angularjs capistrano3


    【解决方案1】:

    这表示服务器上没有安装 NPM 或者不在部署用户的路径中。

    如果你 ssh 进入服务器并运行npm --version,它会返回任何内容吗?

    你可能想试试https://github.com/capistrano/npm/

    【讨论】:

    • 它确实返回了 nam 版本。当我运行which npm 我得到/usr/bin/npm 我不明白为什么Capistrano 在/usr/bin/env 上寻找节点
    • 这里解释了env的原因:capistranorb.com/documentation/faq/…
    • 您好。感谢您的回复。我之前看过那个帖子。它确实解释了原因,但没有解释如何解决它。我有 capistrano/node,但我认为该模块已过时,也无法正常工作
    猜你喜欢
    • 2013-01-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多