ENOTFOUND与打字安装(Nodejs)

时间:2016-08-11 15:41:01

标签: node.js npm typescript-typings

我在我的一个TypeScript项目中使用Typings。运行命令安装类型定义时遇到问题:

$ node_modules/.bin/typings install
typings ERR! message Unable to read typings for "angular". You should check the entry paths in "angular.d.ts" are up to date
typings ERR! caused by Unable to connect to "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/7ce80dafc0df189d61950e80e04548d8304d1538/angularjs/angular.d.ts"
typings ERR! caused by getaddrinfo ENOTFOUND raw.githubusercontent.com raw.githubusercontent.com:443

它似乎无法获得angular.d.ts(ENOTFOUND)。但我对此感到困惑,因为我可以用卷曲来解决这个问题:

$ curl "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/7ce80dafc0df189d61950e80e04548d8304d1538/angularjs/angular.d.ts"
// Type definitions for Angular JS 1.4+
// Project: http://angularjs.org
. . .

有什么想法吗?为什么typings / node无法找到defs类型?

Node 6.3.0
Typings 1.3.2
npm 3.10.5

修改

我制作了一个简单的节点脚本来尝试重现问题。不幸的是,我无法重现它 - 这个脚本工作正常,即使typings install始终产生错误。

var https = require('https');
var options = {
    host: 'raw.githubusercontent.com',
    path: '/DefinitelyTyped/DefinitelyTyped/7ce80dafc0df189d61950e80e04548d8304d1538/angularjs/angular.d.ts',
    port: 443
};

var req = https.get(options, function(res) {
    var str = '';
    console.log(options.host + ':' + res.statusCode);

    res.on('data', function(chunk) {
        str += chunk;
    });

    res.on('end', function() {
        console.log(str);
    });
}).on('error', function(err) {
    console.log('ERROR! ' + err);
});

编辑2

wget因证书错误而失败。不确定这是否完全相关:

$ wget "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/7ce80dafc0df189d61950e80e04548d8304d1538/angularjs/angular.d.ts"
--2016-08-16 20:00:13--  https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/7ce80dafc0df189d61950e80e04548d8304d1538/angularjs/angular.d.ts
Resolving raw.githubusercontent.com... 151.101.48.133
Connecting to raw.githubusercontent.com|151.101.48.133|:443... connected.
ERROR: certificate common name “www.github.com” doesn’t match requested host name “raw.githubusercontent.com”.
To connect to raw.githubusercontent.com insecurely, use ‘--no-check-certificate’.

0 个答案:

没有答案