Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
TypeScript节点示例赢得';不编译_Typescript_Tsc - Fatal编程技术网

TypeScript节点示例赢得';不编译

TypeScript节点示例赢得';不编译,typescript,tsc,Typescript,Tsc,似乎每个人都有样品,但我的样品不会 我在windows 7 64位中安装了nodejs 0.8.2。npm安装了-g typescript以获得typescript支持。然后我从TypeScript下载了源代码并尝试了这些示例 但我就是无法编译节点示例。它返回错误消息: c:\..\..\typescript\bin\tsc.js:21182 if(_fs.existsSync(path)) { ^ TypeError: Object #

似乎每个人都有样品,但我的样品不会

我在windows 7 64位中安装了nodejs 0.8.2。npm安装了-g typescript以获得typescript支持。然后我从TypeScript下载了源代码并尝试了这些示例 但我就是无法编译节点示例。它返回错误消息:

c:\..\..\typescript\bin\tsc.js:21182
           if(_fs.existsSync(path)) {
                  ^
TypeError: Object #(Object) has no method 'existsSync'
...
...
还有谁见过这个问题吗

我到处找了好几个小时,什么也没找到

假设我有这个代码:

///<reference path="node.d.ts"/>


import http = module("http");

var server = http.createServer(function (req, res)
{
    res.writeHead(200, { 'ContenType': 'text/plain' });
    res.end('Hello World');
});

server.listen(1337);
///
导入http=模块(“http”);
var server=http.createServer(函数(req,res)
{
res.writeHead(200,{'ContenType':'text/plain'});
res.end(“你好,世界”);
});
听(1337);
在Visual 2012 express for web中键入此内容,未显示任何错误。参考已经就位,intellisense工作正常。但是,当我使用带有node的命令行工具编译此文件时,它会弹出进一步显示的错误。。我没有在自己的代码中包含_fs.existsSync

好的。。。在玩了tsc.js和nodejs之后。。。我意识到从节点引擎中的require('fs')创建的_fs对象根本没有名为existsSync的函数

再搜索一点。。。显然这个函数现在在路径模块下。。。
我将尝试编辑tsc.js以使用path模块的existsSync函数。

我认为问题在于您的代码中存在键入错误。尝试使用
fs.existsSync(path)
。您正在尝试将方法分配给不存在的对象

fs.existsSync('path/to/file');
fs.exists()
与上述内容同义,只有在连接成功时才使用回调

fs.exists('/path/to/file', function (exists) {
  util.debug(exists ? "it's there" : "no passwd!");
});

好的。。。将tsc.js改为使用_path.existsSync,这样似乎可以工作。 但经过更多的修改,我发现我的系统上的节点版本仍然是v0.6.2。 尽管我曾尝试安装从网站下载的v0.8.12。 移除v0.6.2并安装v0.8.14后,现在fs模块包含目标功能


我想知道为什么这个系统上的节点版本卡在了0.6.2 ~''.

hmmm上。。。但那不是我的密码。。。这是从codeplex下载的typescript源文件中给出的示例…您看到typescript节点示例中的示例了吗?喜欢在引用node.d.ts时,如果我刚刚导入了http=module(“http”);在代码中,编译器将无法找到问题。。。这是因为当我试图用nodejs.org上的安装程序安装时,这个系统上的节点版本没有更新到0.8.xx。它被版本0.6.2卡住了,可能是因为它是32位版本,我试图用64位安装程序更新它。无论如何谢谢你的帮助。