[英]requiring an npm module using typescript
I'm working on a new nodejs 5.10.1 project using typescript. 我正在使用打字稿进行新的nodejs 5.10.1项目。
I have tsc installed version 1.8.9 我已经安装了tsc 1.8.9版本
I created a new project that contains the following configuration files: 我创建了一个新项目,其中包含以下配置文件:
package.json package.json
{
"name": "mdb-analyze",
"version": "1.0.0",
"description": "",
"main": "mdb-analyze.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"command-line-args": "^2.1.6"
}
}
tsconfig.json tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": false,
"sourceMap": false
},
"exclude": [
"node_modules"
]
}
typings.json Types.json
{
"name": "mdb-analyze",
"version": false,
"dependencies": {}
}
and this is my main mdb-analyze.ts file: 这是我的主要mdb-analyze.ts文件:
import * as commandLineArgs from 'command-line-args';
var cli = commandLineArgs([
{ name: 'verbose', alias: 'v', type: Boolean },
{ name: 'fjso', alias:'f',type: String, multiple: true, defaultOption: true },
{ name: 'help',alias:'h',type:Boolean }
])
var params = cli.parse();
if (params.help || !params.fjso || params.fjso.length == 0) {
console.info(cli.getUsage());
} else {
}
when I try to compile with tsc i get the following error: 当我尝试使用tsc进行编译时,出现以下错误:
mdb-analyze.ts(5,34): error TS2307: Cannot find module 'command-line-args'.
welp i've been told to use typings to load typescript definitions for the modules i want. 有人告诉我,使用类型为我想要的模块加载打字稿定义。 but searching on typings doesn't show this module. 但是搜索类型不显示此模块。 i'm new to typescript, and very confused on what to do next. 我是Typescript的新手,对下一步该怎么做很困惑。
any information regarding the issue would be greatly appreciated. 任何有关此问题的信息将不胜感激。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.