请问怎么在.ts中引用node系统库呢,如http、fs等,没有他们的d.ts啊
import http = require(“http”)
ts编译时候报错Cannot find module ‘http’
ps: 如果是常用的第三方库,webstorm里面有集成,找到对应的d.ts加上就好了 /// <reference path="…/…/libs/underscore.browser.d.ts"/>
npm install typings -g
typings init
typings install node --ambient --save
你搜下typings
typings install http --ambient --save typings ERR! message Unable to find “http” for “dt” in the registry
我在webstorm里面也找了,没有http的dt, 其他的node系统库也没有,怎么破?
@louislve , http 是node里的,你装node就行了
@hellopao 给力
@hellopao 但是编译ts的时候提示找不到http啊,而且没有代码提示。
@louislve 检查下node.d.ts是不是正确安装,webstorm我没用过,不知道是怎么引用.d.ts的,你可以把下载下来的node.d.ts放到指定目录,ts文件里的reference的path指向那个地址就好。http是node里的,你装了node.d.ts就有。
@hellopao 可以了,谢谢你