1
我正在尝试以最正确的方式导入节点模块。我想行:使用类型和NPM在TypeScript中安装节点模块
import * as pg from "pg"
工作。但现在它提高了:
Cannot find module 'pg' error
。
我希望我缺少一些简单的东西。
我的失败策略:
npm install pg --save
typings install pg --save
- 在tsconfig.json
"files": [ "./typings/index.d.ts",
。
如果您对我的方法有任何建议,请告诉我。
打字稿哪个版本您使用的导入? –
我在编译或运行时引发这个错误? – martin
如果您使用的是TypeScript 2,这可能很有趣:http://stackoverflow.com/a/38444504/5115768 – lenny