I`m using nvm chef cookbook with nvm_install resource to install nodejs and npm.
nvm_install 'v4.2.2' do
from_source false
alias_as_default true
action :create
end
After install node I tried to run 'npm install' but i had this error:
No such file or directory - npm
I`ve tried to put a "source" to load nvm.sh script but didnt work when I run chef-client at the first time.
append_if_no_line "Global .bashrc and source to nvm" do
path "/etc/bash.bashrc"
line "[[ -s #{node['nvm']['directory']}/nvm.sh ]] && . #{node['nvm']['directory']}/nvm.sh # This loads NVM"
end
My question is, How can I run NPM INSTALL after install NVM/NODE with the chef-client running.
CODE:
nvm_install 'v4.2.2' do
from_source false
alias_as_default true
action :create
end
append_if_no_line "Global .bashrc and source to nvm" do
path "/etc/bash.bashrc"
line "[[ -s #{node['nvm']['directory']}/nvm.sh ]] && . #{node['nvm']['directory']}/nvm.sh # This loads NVM"
end
execute "npm install" do
cwd "#{PATH_CODE}"
command "npm install"
action :run
end