I have a fairly vanilla Vagrant box configured using Puphpet with Node installed.
However, when I ssh into the box and try npm install I seem to be having a raft of permissions issues.
Even running with sudo doesn't seem to work
Running into
npm ERR! tar.unpack untar error /home/vagrant/.npm/gulp-autoprefixer/2.1.0/package.tgz
npm ERR! tar.unpack untar error /home/vagrant/.npm/gulp-concat/2.5.2/package.tgz
npm ERR! tar.unpack untar error /home/vagrant/.npm/gulp-livereload/3.8.0/package.tgz
npm ERR! tar.unpack untar error /home/vagrant/.npm/path/0.11.14/package.tgz
npm ERR! tar.unpack untar error /home/vagrant/.npm/gulp-notify/2.2.0/package.tgz
npm ERR! tar.unpack untar error /home/vagrant/.npm/gulp-compass/2.0.3/package.tgz
npm ERR! tar.unpack untar error /home/vagrant/.npm/gulp-minify-css/0.4.6/package.tgz
npm ERR! tar.unpack untar error /home/vagrant/.npm/gulp-plumber/0.6.6/package.tgz
npm ERR! tar.unpack untar error /home/vagrant/.npm/gulp-rename/1.2.0/package.tgz
npm ERR! tar.unpack untar error /home/vagrant/.npm/gulp/3.8.11/package.tgz
npm ERR! tar.unpack untar error /home/vagrant/.npm/gulp-uglify/1.1.0/package.tgz
npm ERR! Linux 3.13.0-32-generic
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v0.12.0
npm ERR! npm v2.5.1
npm ERR! path /var/www/node_modules/gulp-autoprefixer/package.json
npm ERR! code EPERM
npm ERR! errno -1
npm ERR! Error: EPERM, chown '/var/www/node_modules/gulp-autoprefixer/package.json'
npm ERR! at Error (native)
npm ERR! { [Error: EPERM, chown '/var/www/node_modules/gulp-autoprefixer/package.json']
npm ERR! errno: -1,
npm ERR! code: 'EPERM',
npm ERR! path: '/var/www/node_modules/gulp-autoprefixer/package.json',
npm ERR! fstream_finish_call: 'chown',
npm ERR! fstream_type: 'File',
npm ERR! fstream_path: '/var/www/node_modules/gulp-autoprefixer/package.json',
npm ERR! fstream_class: 'FileWriter',
npm ERR! fstream_stack:
npm ERR! [ '/usr/local/lib/node_modules/npm/node_modules/fstream/lib/writer.js:308:19',
npm ERR! '/usr/local/lib/node_modules/npm/node_modules/graceful-fs/polyfills.js:143:7',
npm ERR! 'FSReqWrap.oncomplete (evalmachine.<anonymous>:99:15)' ] }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! Please include the following file with any support request:
npm ERR! /var/www/npm-debug.log
I've read about writing into a shared folder and tried adding fixes to the Vagrantfile but with no success
virtualbox.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"]
Any ideas?
So turns out this was a bug with the Puphpet config like so https://github.com/puphpet/puphpet/issues/1378
The fix can be found in https://github.com/puphpet/puphpet/pull/1403 - just had to replace that snippet in my Vagrantfile and we're sweet. I can now npm install, bundle install etc.
Are you using Windows? Not only do you need to customize the VM, but you also need to start the VM while you have elevated rights (ie Run as Administrator). Overall, it is a complex mess.
If I'm working with something that needs symlinks in my shared folder (like npm), I've started using rsync folders. With rsync the /vagrant folder is no longer a Virtual Box shared folder, and doesn't have problems representing symlinks. As an extra benefit, it is also way faster.
Related
I'm trying to view someone else's Meteor project from Github. I cloned it then tried running it by typing 'meteor' but what results is this slew of errors. I've included a sample below. I am running the command prompt as administrator. Clearly this has something to do with Node or its packages but I'm at a loss of where I should go with this. If someone could give me a hint I would be grateful.
npm http GET https://registry.npmjs.org/camelcase
npm http GET https://registry.npmjs.org/map-obj
npm http 304 https://registry.npmjs.org/mime-db
npm http GET https://registry.npmjs.org/get-stdin
npm http GET https://registry.npmjs.org/repeating
npm http 304 https://registry.npmjs.org/async
etc. etc....
npm ERR! error rolling back errno: 50,
npm ERR! error rolling back code: 'EPERM',
npm ERR! error rolling back path:
'C:\Users\Kyle\Documents\Websites...
npm ERR! 'Object.oncomplete (fs.js:108:15)' ] }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! System Windows_NT 6.2.9200
npm ERR! command
"C:\Users\Kyle\AppData\Local\.meteor\packages\meteor-tool\1.1.10\mt-os.windows.x86_32\dev_bundle\bin\\node.exe"
"C:\Users\Kyle\AppData\Local\.meteor\packages\meteor-tool\1.1.10\mt-
os.windows.x86_32\dev_bundle\bin\node_modules\npm\bin\npm-cli.js"
"install"
npm ERR! cwd
C:\Users\Kyle\Documents\Websites\thisWebsite\packages\npm-container.npm\package-new-14v2dj3
npm ERR! fstream_type File
npm ERR! fstream_class FileWriter
npm ERR! fstream_finish_call chmod
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR! fstream_stack
C:\Users\Kyle\AppData\Local.meteor\packages\meteor-tool\1.1.10\mt-os.windows.x86_32\dev_bundle\bin\node_modules\npm\node_modules\fstream\lib\writer.js:305:19
npm ERR! fstream_type Directory npm
ERR! fstream_class DirWriter
npm ERR! code EPERM
npm ERR! errno 50
npm ERR! stack Error:
EPERM, mkdir
npm ERR! node -v v0.10.40
npm ERR! npm -v 1.4.9
npm ERR! path...
npm ERR! fstream_stack Object.oncomplete (fs.js:108:15)
npm ERR!
Error: version not found: ansi-styles#2.2.0
npm ERR! at
C:\Users\Kyle\AppData\Local.meteor\packages\meteor-tool\1.1.10...
npm ERR! at Object.oncomplete (fs.js:108:15)
npm ERR! If you need help, you may report this entire log,
npm ERR! including the npm and node versions, at:
npm ERR! http://github.com/npm/npm/issues
npm ERR! System Windows_NT 6.2.9200
npm ERR! command
"C:\Users\Kyle\AppData\Local\.meteor\packages\meteor-tool\1.1.10\mt-os.windows.x86_32\dev_bundle\bin\\node.exe"
Try running the CMD / Powershell with Administrator (Run as Administrator). and then install npm dependencies as Github usually don't store them do: npm install and npm start. If you keep getting the errors. go to C:\Program Files\nodejs\node_modules\
or where your nodejs is installed and do right click, choose 'Properties' and go to 'Security' tab and give privileges to the user you need and try running npm install. Good luck
This worked in my particular case:
Remove meteorhacks and npm-container by typing this in the console:
meteor remove meteorhacks:npm npm-container
Delete the 'npm-container' folder which is generated by the package.
Run 'npm init' to create a package.json
Copy the contents of packages.json to the dependencies section of package.json
I have a nodejs docker instance running in Windows.
I have mounted a write-enabled windows directory to the docker instance.
I am trying to install shelljs into my project but it is failing with a following error:
npm ERR! Linux 4.0.9-boot2docker
npm ERR! argv "/opt/nodejs/bin/node" "/usr/bin/npm" "install" "shelljs"
npm ERR! node v4.1.2
npm ERR! npm v2.14.4
npm ERR! path ../shelljs/bin/shjs
npm ERR! code EPROTO
npm ERR! errno -71
npm ERR! syscall symlink
npm ERR! EPROTO: protocol error, symlink '../shelljs/bin/shjs' -> '/home/app/meteor-webpack-react/node_modules/.bin/shjs'
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! Linux 4.0.9-boot2docker
npm ERR! argv "/opt/nodejs/bin/node" "/usr/bin/npm" "install" "shelljs"
npm ERR! node v4.1.2
npm ERR! npm v2.14.4
npm ERR! path npm-debug.log.907b6eb81436ba935104c98d206fb37c
npm ERR! code ETXTBSY
npm ERR! errno -26
npm ERR! syscall rename
npm ERR! ETXTBSY: text file is busy, rename 'npm-debug.log.907b6eb81436ba935104c98d206fb37c' -> 'npm-debug.log'
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR! /home/app/meteor-webpack-react/npm-debug.log
Please note that I have enabled symlink creation (http://www.ahtik.com/blog/fixing-your-virtualbox-shared-folder-symlink-error/) and they can be done manually via ln -s. I am running a machine as administrator.
Any idea of why the symlinks are failing. I thought that it is because the npm cache is in the virtual machine trying to symlink to windows directory, but trying to move cache to windows directory failed as well (npm config set cache ~/.npm --global)
Have you made sure you have installed Virtualbox Extension Pack for the right version of VirtualBox? Usually that is the culprit.
I created a new user on my Mac and tried this. This normally works in my other account. This new user is an administrator also.
npm ERR! tar.unpack untar error /Users/test/.npm/webpack/1.11.0/package.tgz
npm ERR! Darwin 14.4.0
npm ERR! argv "node" "/usr/local/bin/npm" "install" "-g" "webpack"
npm ERR! node v0.12.4
npm ERR! npm v2.10.1
npm ERR! path /usr/local/lib/node_modules/webpack
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/webpack'
npm ERR! at Error (native)
npm ERR! { [Error: EACCES, mkdir '/usr/local/lib/node_modules/webpack']
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! path: '/usr/local/lib/node_modules/webpack',
npm ERR! fstream_type: 'Directory',
npm ERR! fstream_path: '/usr/local/lib/node_modules/webpack',
npm ERR! fstream_class: 'DirWriter',
npm ERR! fstream_stack:
npm ERR! [ '/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:35:25',
npm ERR! '/usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:47:53',
npm ERR! 'FSReqWrap.oncomplete (fs.js:95:15)' ] }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/test/WebstormProjects/babel-test/npm-debug.log
I am not very good with the UNIX stuff and things, I just wish these things would be more easy.
From the looks of it, since it says EACCES, it is probably getting an access denied from the system. If you are installing globally on unix you must use sudo.
$ sudo npm install -g webpack
Start using nvm and it will save you from using sudo at all.
https://github.com/creationix/nvm
I have a vagrant VM with Ubuntu 14 64bit. My host is Windows 8.1. I'm trying to make an npm install on a shared folder (a nodejs app) but even with a
npm install --no-bin-links
it fails with
npm ERR! tar.unpack untar error /root/.npm/node-pre-gyp/0.6.8/package.tgz
npm ERR! tar.unpack untar error /root/.npm/node-pre-gyp/0.6.8/package.tgz
npm ERR! tar.unpack untar error /root/.npm/lodash-node/2.4.1/package.tgz
npm ERR! Linux 3.2.0-23-generic
npm ERR! argv "/usr/local/node/node-v0.12.7/bin/node" "/usr/local/node/node-default/bin/npm" "install" "--no-bin-links"
npm ERR! node v0.12.7
npm ERR! npm v2.11.3
npm ERR! path /vagrant_data/fe/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/fs-extra/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_
modules/brace-expansion/node_modules/concat-map/package.json.1e22b31c2e50debaced0adc67bb0250c
npm ERR! code EPERM
npm ERR! errno -1
npm ERR! Error: EPERM, open '/vagrant_data/fe/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/fs-extra/node_modules/rimraf/node_modules/glob/node_modules/
minimatch/node_modules/brace-expansion/node_modules/concat-map/package.json.1e22b31c2e50debaced0adc67bb0250c'
npm ERR! at Error (native)
npm ERR! { [Error: EPERM, open '/vagrant_data/fe/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/fs-extra/node_modules/rimraf/node_modules/glob/node_modu
les/minimatch/node_modules/brace-expansion/node_modules/concat-map/package.json.1e22b31c2e50debaced0adc67bb0250c']
npm ERR! errno: -1,
npm ERR! code: 'EPERM',
npm ERR! path: '/vagrant_data/fe/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/fs-extra/node_modules/rimraf/node_modules/glob/node_modules/minimatch/n
ode_modules/brace-expansion/node_modules/concat-map/package.json.1e22b31c2e50debaced0adc67bb0250c' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! Linux 3.2.0-23-generic
npm ERR! argv "/usr/local/node/node-v0.12.7/bin/node" "/usr/local/node/node-default/bin/npm" "install" "--no-bin-links"
npm ERR! node v0.12.7
npm ERR! npm v2.11.3
npm ERR! path npm-debug.log.2e07d69aba2393c854d2992b7057b4c0
npm ERR! code ETXTBSY
npm ERR! errno -26
npm ERR! ETXTBSY, rename 'npm-debug.log.2e07d69aba2393c854d2992b7057b4c0'
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR! /vagrant_data/fe/npm-debug.log
and I really can't understand why. My npm version is 2.11.3.
Can you help me?
I'll answer my own question, maybe it will be useful to someone. It's a Vagrant bug, here's the fix:
Github link
EDIT
for those who need some detail: I'm running Vagrant 1.7.2 and VirtualBox 4.3.28.
What I did to solve my problem was to edit the file
# Lines 495-510 - C:\HashiCorp\Vagrant\embedded\gems\gems\vagrant-1.7.2\plugins\providers\virtualbox\driver\version_4_3.rb
def share_folders(folders)
folders.each do |folder|
args = ["--name",
folder[:name],
"--hostpath",
- folder[:hostpath]]
+ '\\\\?\\' + folder[:hostpath].gsub(/[\/\\]/,'\\')]
args << "--transient" if folder.key?(:transient) && folder[:transient]
# Enable symlinks on the shared folder
execute("setextradata", #uuid, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/#{folder[:name]}", "1")
# Add the shared folder
execute("sharedfolder", "add", #uuid, *args)
end
end
as shown in the Celtric comment (HERE the link).
So the issue is basicly simple - npm install doesn't work on my Vagrant setup via Ansible, but works excellent, when I run it from console
CASE 1)
I have some playbook with lines:
...
- name: install frontend libs
npm: path=/vagrant/frontend/bem
...
When I run vagrant provision, when it comes to this point, it crashes 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 look for rights in node_modules folder it has drwxr-xr-x rights.
CASE 2)
When I go to my VM and run npm install manually, it works fine, and node_modules rights are drwxrwxr-x.
So the question - how can I achieve the same behavior via ansible?
With which user are you running this npm command? You might want to run it as another user:
- name: install frontend libs
npm: path=/vagrant/frontend/bem
sudo: yes
sudo_user: someuser