【发布时间】:2016-04-07 05:33:24
【问题描述】:
简而言之:
- Node.js 项目,从 javascript 更改为 typescript
- npm install mongoose
- typings install mongoose --save --ambient
如果我这样做'import mongoose = require("mongoose");'并输入执行 gulp 我得到:
server/categories/categories.model.ts(1,29): error TS2656:
Exported external package typings file
'/vagrant/node_modules/mongoose/index.ts' is not a module.
Please contact the package author to update the package definition.
在 Visual Studio Code 中,如果我悬停,消息是相同的,但另一方面它使用类型定义,因为我可以正常解析我的 mongoose-Module。我不明白为什么它认为 index.ts 应该是类型定义。
我不太确定这些信息是否足够,如果没有,请告诉我。
提前致谢。
摘录:
-
gulpfile.js
var tsProject = tsc.createProject("tsconfig.json"); gulp.task("build", function() { return gulp.src([ "server/**/**.ts", "typings/main.d.ts" ]) .pipe(tsc(tsProject)) .js.pipe(gulp.dest("server/")); }); -
tsconfig.json
"compilerOptions": { "target": "es5", "sourceMap": true, "module": "commonjs", "moduleResolution": "node", "isolatedModules": false, "jsx": "react", "experimentalDecorators": true, "emitDecoratorMetadata": true, "declaration": false, "noImplicitAny": false, "removeComments": true, "noLib": false, "preserveConstEnums": true, "suppressImplicitAnyIndexErrors": true }, "filesGlob": [ "**/*.ts", "**/*.tsx", "!node_modules/**", "!typings/browser/**" ]
【问题讨论】:
标签: node.js module typescript gulp