如何在capistrano-node-deploy中禁用共享文件夹选项

时间:2015-02-03 20:34:59

标签: node.js npm capistrano

如果您的发布文件夹中有非发布目录,则npm install命令将失败,如下所示,

  * executing `node:install_packages'
  * executing "ls -x /home/ubuntu/support/releases"
    servers: ["spp"]
    [spp] executing command
    command finished in 296ms
  * executing "mkdir -p /home/ubuntu/support/releases/surveys.csv/node_modules ; cp -r /home/ubuntu/support/releases/surveys.csv/node_modules /home/ubuntu/support/releases/20150203163509"
    servers: ["spp"]
    [spp] executing command
 ** [out :: spp] mkdir:
 ** [out :: spp] cannot create directory `/home/ubuntu/support/releases/surveys.csv'
 ** [out :: spp] : Not a directory
 ** [out :: spp] 
 ** [out :: spp] cp:
 ** [out :: spp] cannot stat `/home/ubuntu/support/releases/surveys.csv/node_modules'
 ** [out :: spp] : Not a directory
 ** [out :: spp] 
    command finished in 307ms
*** [deploy:update_code] rolling back

这里是发布目录的样子......

> ls -lt
total 66324
drwxrwsr-x 13 ubuntu ubuntu     4096 Feb  3 05:58 20150109231012
-rw-rw-r--  1 ubuntu ubuntu   672733 Feb  1 10:01 surveys.csv
drwxrwsr-x 13 ubuntu ubuntu     4096 Dec 10 19:15 20141210191517

项目认为这是一项功能,但在部署新版本时,我宁愿不尝试共享/复制旧的node_modules目录。

有没有办法将其关闭?

1 个答案:

答案 0 :(得分:0)

失败是因为surveys.csv文件比previous_release目录更新,如果再次部署它应该会有效。

您可以覆盖node:install_packages任务:

Rake::Task["node:install_packages"].clear_actions
namespace :node do
  task :install_packages do
    run "cd #{release_path} && npm install --loglevel warn"
  end
end