【问题标题】:Cannot install NPM on Vagrant during provision配置期间无法在 Vagrant 上安装 NPM
【发布时间】:2013-11-24 12:23:26
【问题描述】:

在 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

Node 设置为魅力,但 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

我已经用谷歌搜索了大约两天 - 找不到任何解决方案:(

UPD

如果要像这样设置 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

【问题讨论】:

    标签: node.js npm vagrant provisioning


    【解决方案1】:

    安装脚本尝试访问/dev/tty 以询问它是否应该清理旧版本,这显然不适用于无 gui 的流浪盒。您也可以使用环境变量clean 设置此行为,因此不必询问:

    将 curl 语句更改为:curl https://npmjs.org/install.sh | sudo clean=no sh

    如果您愿意,也可以使用clean=yes

    【讨论】:

    • 非常感谢,但这个技巧没有奏效:(日志说在 curl 之前 mknod: `/dev/tty': File exists 之后出现同样的错误
    • 请看一下 UPD 帖子
    【解决方案2】:

    万一有人尝试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 前缀。

    【讨论】:

    • 是的,但这与提出的问题无关
    • 和这个问题没有任何关系
    • 这个答案虽然与问题无关,但对我有所帮助。当我用谷歌搜索“npm 无法打开 html:没有这样的文件”时,我来到了这里,所以......:P
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-10-22
    • 2015-04-29
    • 2015-04-25
    • 1970-01-01
    • 2021-01-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多