Cannot install NPM on Vagrant during provision-Collection of common programming errors

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 🙁

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