2012-11-11 323 views
6

我有以下表現:流浪,木偶和模塊的NodeJS:在NPM模塊安裝拋出錯誤

include nodejs 

package { 'serve': 
    ensure => latest, 
    provider => 'npm', 
} 

我使用Node.js的puppetlab模塊:

http://forge.puppetlabs.com/puppetlabs/nodejs

Vagrantfile:

Vagrant::Config.run do |config| 
    config.vm.box = "precise64" 
    config.vm.box_url = "http://files.vagrantup.com/precise64.box" 

    config.vm.provision :puppet do |puppet| 
    puppet.manifests_path = '~/work/environments/default/' 
    puppet.manifest_file = 'site.pp' 
    puppet.module_path = '~/work/environments/default/modules' 
    end 

end 

當我運行vagrant up我得到以下錯誤:

[default] Running provisioner: Vagrant::Provisioners::Puppet... 
[default] Running Puppet with /tmp/vagrant-puppet/manifests/site.pp... 
stdin: is not a tty 
err: /Stage[main]//Package[serve]/ensure: change from absent to latest failed: Could not update: Got nil value for ensure at /tmp/vagrant-puppet/manifests/site.pp:6 
notice: /Stage[main]/Nodejs/Package[nodejs]/ensure: ensure changed 'purged' to 'present' 
notice: /Stage[main]/Nodejs/Package[npm]/ensure: ensure changed 'purged' to 'present' 
notice: Finished catalog run in 14.89 seconds 

起初我想,也許它正試圖安裝NPM之前安裝的「服務」模塊,所以我嘗試require => Package[npm]但給了相同的結果。

因此,任何人都可以關注爲什麼不安裝'serve'模塊?

回答

8

它似乎在訂購 - 供應商需要npm命令,這是你還沒有的。

試着改變你的清單,以這樣的:

class { 'nodejs': } -> package { 'serve': ensure => present, provider => 'npm', } 

或者,可能是:

include nodejs 

package { 'serve': 
    ensure => present, 
    provider => 'npm', 
    require => Package['npm'], 
} 
+0

您如何要求Package ['npm']?它似乎沒有被定義(「無法找到依賴包[npm]」) – Karan

+0

你可以做「require => Class ['nodejs'],」 –

11

我碰到這個跑以及 - 它看起來對我來說,模塊是不是就-的NodeJS puppetlabs實際上接受ensure => latest,這與文檔相反。例如,當我更改爲ensure => present時,我的問題得到修復,代碼看起來也支持特定的版本,例如ensure => 1.12.4

+0

是的,這是正確的答案! –

+0

有一個拉取請求可以解決這個問題,但是如果有人想幫助解決這個問題,它目前正在失敗它的Travis構建:https://github.com/puppetlabs/puppetlabs-nodejs/pull/78 – ScottSB