Cannot install NPM on Vagrant during provision
node.js, npm, provisioning, vagrant
Solution
The install script tries to access `/dev/tty` to ask if it should clean old versions, which apparently doesnt work with gui-less vagrant boxes. You can set this behaviour using the environment variable `clean`, too, so it doesnt have to ask:
Change the curl statement to this: `curl https://npmjs.org/install.sh | sudo clean=no sh`.
You can use `clean=yes`, too, if you prefer.
Problem
During Vagrant Shell provision I try to install NodeJS and NPM on Debian Wheezy. Script is (from guide https://github.com/joyent/node/wiki/backports.debian.org): ``` sudo echo "deb http://ftp.us.debian.org/debian wheezy-backports main" >> /etc/apt/sources.list sudo apt-get update sudo apt-get install -y nodejs-legacy curl https://npmjs.org/install.sh | sudo sh ``` Node sets up as a charm, but NPM installation fails: Stderr from the command: ``` stdin: is not a tty dpkg-preconfigure: unable to re-open stdin: No such file or directory % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 7810 100 7810 0 0 1407 0 0:00:05 0:00:05 --:--:-- 18956 fetching: http://registry.npmjs.org/npm/-/npm-1.3.15.tgz npm-install-2877.sh: 270: npm-install-2877.sh: cannot open /dev/tty: No such device or address Aborted 0.x cleanup. Exiting. It failed ``` I've googled about two days - can't find any solution :( UPD If to set a Vagrant config like this: ``` config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'" ``` Then script doesn't say anything about tty, but still fails: ``` Stderr from the command: dpkg-preconfigure: unable to re-open stdin: No such file or directory % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 7810 100 7810 0 0 1412 0 0:00:05 0:00:05 --:--:-- 19772 fetching: http://registry.npmjs.org/npm/-/npm-1.3.15.tgz npm-install-3013.sh: 270: npm-install-3013.sh: cannot open /dev/tty: No such device or address Aborted 0.x cleanup. Exiting. It failed ```