node.js - Vagrant,为 Node.js 设置机器 - Chef 失败

标签 node.js vagrant chef-infra

我的 Vagrantfile:

Vagrant::Config.run do |config|
  config.vm.box = "lucid32"
  config.ssh.forward_agent = true
  config.vm.forward_port 3000, 3000

  # allow for symlinks in the app folder
  config.vm.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/app", "1"]
  config.vm.customize ["modifyvm", :id, "--memory", 512, "--cpus", 1]

  config.vm.provision :chef_solo do |chef|
    chef.cookbooks_path = "cookbooks"

    chef.add_recipe "apt"
    chef.add_recipe "build-essential"
    chef.add_recipe "nodejs-cookbook"
    chef.add_recipe "chef-hosts"
    chef.add_recipe "git"
    chef.json = {
      "nodejs" => {
        "version" => "0.8.12",
        "install_method" => "source",
        "npm" => "1.1.62"
      },
      "host_aliases" => [{
        "name" => "awesomeapp",
        "ip" => "127.0.0.1"
      }]
    }
  end
end

当我运行 vagrant reload 时,我从 Chef 那里得到了以下异常:

[2012-11-25T07:58:23+01:00] ERROR: Running exception handlers
[2012-11-25T07:58:23+01:00] ERROR: Exception handlers complete
[2012-11-25T07:58:24+01:00] FATAL: Stacktrace dumped to /tmp/vagrant-chef-1/chef-stacktrace.out
[2012-11-25T07:58:24+01:00] FATAL: Chef::Exceptions::CookbookNotFound: Cookbook nodejs not found. If you're loading nodejs from another cookbook, make
sure you configure the dependency in your metadata
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.

已解决:在 cookbook 文件夹中,我将 nodejs-cookbook 重命名为 nodejs 并更正了 Vagrant 文件。

chef.add_recipe "nodejs-cookbook"

跑完后

vagrant provision

一切都安装好了!

最佳答案

add_recipe 应该是 Recipe 的名称。例如文件结构:

Recipe/nodejs

重要的是:

cookbooks/nodejs/metadata.rb 应该包含:name "nodejs"

关于node.js - Vagrant,为 Node.js 设置机器 - Chef 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13549020/

相关文章:

javascript - Node js正常文件上传代码在执行时显示错误

node.js - Nodemon + Vagrant + Mongodb

linux - Chef 运行时未使用 Chef DataBag 值

chef-infra - 如何安装knife-ec2插件?

JavaScript 相当于 PHP 的 Compact() 方法?

javascript - 无法等待 Node.js 中的 sqlite3.Database.get() 函数完成

virtualbox - 使用 Vagrant 获取当前 VirtualBox 状态

Vagrant up 无法在 mac OS X 中工作

git - 在 vagrant+chef 设置中使用带密码的 ssh key

node.js - 将表单数据邮寄到我的收件箱的应用程序在 Firebase 上无法正常工作