Install npm with the chef, cause my roaming user to have EACCES problem

Env: Ubuntu Precise64 / Hosted Enterprise Chef / Vagrant

When I try to run NPM installation in my application folder through a chef recipe

execute "npm-install" do cwd "/home/my_user/my_nodejs_app" command "npm install" user "my_user" group "sudo" action :run end 

Using a box of strollers

 $ vagrant ssh vagrant@precise64 :~$ sudo chef-client 

I get this error:

 Mixlib::ShellOut::ShellCommandFailed ------------------------------------ Expected process to exit with [0], but received '3' ---- Begin output of npm install ---- STDOUT: STDERR: npm WARN package.json my_cookbook@0.0.0 No readme data. npm ERR! Error: EACCES, mkdir '/home/vagrant/.npm' npm ERR! { [Error: EACCES, mkdir '/home/vagrant/.npm'] errno: 3, code: 'EACCES', path: '/home/vagrant/.npm' } npm ERR! npm ERR! Please try running this command again as root/Administrator. npm ERR! System Linux 3.5.0-23-generic npm ERR! command "/usr/local/src/nvm/v0.8.26/bin/node" "/usr/local/src/nvm/v0.8.26/bin/npm" "install" npm ERR! cwd /home/my_user/my_nodejs_app npm ERR! node -v v0.8.26 npm ERR! npm -v 1.2.30 npm ERR! path /home/vagrant/.npm npm ERR! code EACCES npm ERR! errno 3 npm ERR! stack Error: EACCES, mkdir '/home/vagrant/.npm' npm ERR! npm ERR! Additional logging details can be found in: npm ERR! /home/my_user/my_nodejs_app/npm-debug.log npm ERR! not ok code 0 ---- End output of npm install ---- Ran npm install returned 3 

Why is PATH set as /home/vagrant/.npm and can I fix this?

+6
source share
1 answer

The runtime resource will not touch the environment, so you need to set the HOME variable:

 execute "npm-install" do # ... environment "HOME" => "/home/my_user" end 
+9
source

Source: https://habr.com/ru/post/969615/


All Articles