简而言之:
如果我'导入mongoose = require(“mongoose”);'并输入execute 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/**"
]