在Vagrant Shell配置期间,我尝试在Debian Wheezy上安装NodeJS和NPM。 脚本是(来自指南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
节点设置为魅力,但NPM安装失败:
命令中的Stderr:
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
我用Google搜索了两天 - 找不到任何解决方案:(
如果要设置如下的Vagrant配置:
config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
然后脚本没有说tty,但仍然失败:
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
答案 0 :(得分:14)
安装脚本尝试访问/dev/tty
以询问是否应该清除旧版本,这显然不适用于无需流浪的盒子。您也可以使用环境变量clean
设置此行为,因此不必询问:
将curl语句更改为:curl https://npmjs.org/install.sh | sudo clean=no sh
。
如果您愿意,也可以使用clean=yes
。
答案 1 :(得分:11)
如果有人,请在尝试 curl https://npmjs.org/install.sh 后出现以下错误
sh: 1: cannot open html: No such file
sh: 2: Syntax error: redirection unexpected
尝试执行以下操作:
curl https://www.npmjs.org/install.sh | sudo sh
显然,npm域名需要使用www前缀。