大佬教程收集整理的这篇文章主要介绍了node.js – 使用TypeScript导入节点模块,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
import http = require('http') http.createServer(function (req,res) { res.writeHead(200,{'Content-Type': 'text/plain'}); res.end('Hello World\n'); }).listen(1337,'127.0.0.1'); console.log('Server running at http://127.0.0.1:1337/');
使用命令“tsc app.ts –module’commonjs’”我得到以下错误(不使用–module标志给我一个额外的错误,告诉我,我需要它来编译外部模块):
error TS2071: Unable to resolve external module '"http"'. error TS2072: Module cAnnot be aliased to a non-module type.
>从这里下载node.d.ts文件:https://github.com/borisyankov/DefinitelyTyped/tree/master/node
>在文件的顶部添加:
/// <reference path="node.d.ts" />
PS:查看示例测试文件:https://github.com/borisyankov/DefinitelyTyped/blob/master/node/node-tests.ts
以上是大佬教程为你收集整理的node.js – 使用TypeScript导入节点模块全部内容,希望文章能够帮你解决node.js – 使用TypeScript导入节点模块所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。