如何安装自定义types?

我创build了一个自定义的input包含代码,我想分享几个webstorm node.js项目。 问题是,我正在试图find文件,概述如何在项目中包含input。 我尝试使用npm命令,但没有将该文件夹添加到/ node_modules文件夹下的@typings文件夹中。 此外,当我编译项目,我试图添加自定义打字,我在包含打字的项目和我想添加打字的项目之间的mongoose库重复错误。 我不确定问题可能是什么。

tsconfig.json(对于新types):

{ "name": "newcustomtype", "description": "...", "version": "1.0.0", "main": "./dist/index.js", "typings": "./dist/index.d.ts", "scripts": { "grunt": "grunt" }, "dependencies": { "@types/express": "^4.0.35", "@types/express-jwt": "0.0.34", "debug": "^2.2.0", "dotenv": "^4.0.0", "mongoose": "^4.9.2", "tslint": "^4.5.1" }, "devDependencies": { "@types/mongodb": "^2.1.41", "@types/mongoose": "^4.7.9", "@types/node": "^7.0.10", "grunt": "^1.0.1", "grunt-cli": "^1.2.0", "grunt-contrib-watch": "^1.0.0", "grunt-ts": "^6.0.0-beta.15", "grunt-tslint": "^4.0.1", "nodemon": "^1.11.0", "ts-node": "^3.0.2", "tslint": "^4.5.1", "typescript": "^2.2.1" } } 

tsconfig.json(应该安装input的地方):

 { "compilerOptions": { "module": "commonjs", "target": "ES5", "moduleResolution": "node", "experimentalDecorators": true, "emitDecoratorMetadata": true, "types": ["reflect-metadata"], "lib": ["ES6"], "sourceMap": true, "inlineSources": true, "pretty": true, "outDir": "dist", "rootDir": "src", "noLib": false }, "include": [ "src/**/*.ts" ], "exclude": [ "node_modules" ], "compileOnSave": false } 

我试图按照文档。 在打字稿网站上,但我一直无法find一个资源概述如何安装一旦创build。 虽然,为了不安装自定义input,我想我的tsconfig文件也有问题。 请检阅并让我知道我缺less什么?

提前致谢。

node_modules/@types文件夹仅用于由npm安装的定义。 对于自定义types,最好在你的tsconfig.json 指定 tsconfig.json 。 例如:

 { [...] "compilerOptions": { [...] "typeRoots" : ["../path/to/typings", "./node_modules/@types"], [...] } [...] }