Npm install and Vagrant / Ansible folder chmod issue

So the problem is simple: npm install doesn't work on my Vagrant setup via Ansible, but it works fine when I run it from the console

CASE 1) I have a player with lines:

... 
- name: install frontend libs
  npm: path=/vagrant/frontend/bem
...

      

When I run Vagrant, when it comes to this point, it breaks the superbad:

TASK: [nodejs | install frontend libs] **************************************** 
failed: [default] => {"cmd": "/usr/bin/npm install", "failed": true, "rc": 50}
stderr: npm http GET https://registry.npmjs.org/bem/0.8.1
npm http GET https://registry.npmjs.org/bem-tools-autoprefixer/0.0.3
... 
lots of similar lines here
...
npm ERR! Error: EPERM, chown '/vagrant/frontend/bem/node_modules/enb-bembundle/package.json'
npm ERR!  { [Error: EPERM, chown '/vagrant/frontend/bem/node_modules/enb-bembundle/package.json']
npm ERR!   errno: 50,
npm ERR!   code: 'EPERM',
npm ERR!   path: '/vagrant/frontend/bem/node_modules/enb-bembundle/package.json',
npm ERR!   fstream_finish_call: 'chown',
npm ERR!   fstream_type: 'File',
npm ERR!   fstream_path: '/vagrant/frontend/bem/node_modules/enb-bembundle/package.json',
npm ERR!   fstream_class: 'FileWriter',
npm ERR!   fstream_stack: 
npm ERR!    [ '/usr/lib/nodejs/fstream/lib/writer.js:305:19',
npm ERR!      '/usr/lib/nodejs/graceful-fs/polyfills.js:133:7',
npm ERR!      'Object.oncomplete (fs.js:107:15)' ] }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.
... 
lots of similar lines here
...
npm ERR! System Linux 3.13.0-24-generic
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! cwd /vagrant/frontend/bem
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.3.10
npm ERR! path /vagrant/frontend/bem/node_modules/bem/package.json
npm ERR! fstream_path /vagrant/frontend/bem/node_modules/bem/package.json
npm ERR! fstream_type File
npm ERR! fstream_class FileWriter
npm ERR! fstream_finish_call chown
npm ERR! code EPERM
npm ERR! errno 50
npm ERR! stack Error: EPERM, chown '/vagrant/frontend/bem/node_modules/bem/package.json'
npm ERR! fstream_stack /usr/lib/nodejs/fstream/lib/writer.js:305:19
npm ERR! fstream_stack /usr/lib/nodejs/graceful-fs/polyfills.js:133:7
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /vagrant/frontend/bem/npm-debug.log
npm ERR! not ok code 0

FATAL: all hosts have already failed -- aborting

PLAY RECAP ******************************************************************** 
           to retry, use: --limit @/Users/idmultiship/playbook-web.retry

default                    : ok=24   changed=13   unreachable=0    failed=1   

Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.

      

When I search for rights in the node_modules folder , it has drwxr-xr-x rights .

CASE 2) When I go to my virtual machine and run npm install manually it works fine and node_modules is drwxrwxr-x .

So the question is - how can I achieve the same behavior via an accessible one?

+3


source to share


1 answer


Which user are you running this npm command with? You might want to run it as a different user:



- name: install frontend libs
  npm: path=/vagrant/frontend/bem
  sudo: yes
  sudo_user: someuser

      

0


source







All Articles