[英]TypeDoc can not find Angular2 modules
我正在嘗試使用TypeDoc生成doc文件。 當我使用以下命令運行TypeDoc時:
/node_modules/.bin/typedoc --module system --target ES5 --exclude *.spec.ts* --experimentalDecorators --out typedoc app/ --ignoreCompilerErrors
它給出作為輸出:
Using TypeScript 1.6.2 from /development/node_modules/typedoc/node_modules/typescript/lib
Error: /development/app/angular2/app.ts(1)
Cannot find module 'angular2/core'.
Error: /development/app/angular2/app.ts(2)
Cannot find module 'angular2/upgrade'.
Error: /development/app/angular2/app.ts(3)
Cannot find module 'angular2/platform/browser'.
Error: /development/app/angular2/app.ts(5)
tsconfig.json
{
"compilerOptions": {
"target": "ES5",
"module": "system",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
},
"exclude": [
"node_modules"
]
}
是否有某種我缺少的參數包含libs或.d.ts.
文件?
我嘗試了commonjs模塊,它起作用了。
typedoc --experimentalDecorators --target 'es5' --module 'commonjs' --out doc-destination/ src/
我在angular2應用程序中使用typedoc。 盡管我通過gulp-typedoc運行它,但傳遞的參數應該相同。 以下gulp任務為我完成了這項工作:
gulp.task("doc", function() {
return gulp
.src(["./myproject/**/*.ts"])
.pipe(typedoc({
// TypeScript options (see typescript docs)
module: "commonjs",
target: "es5",
includeDeclarations: false,
experimentalDecorators: true,
// Output options (see typedoc docs)
out: "./docs",
// TypeDoc options (see typedoc docs)
name: "MyProject",
ignoreCompilerErrors: false,
excludeExternals:true,
version: true,
}));
});
希望這可以幫助。
在tsconfig.json中添加類型定義文件的配置,然后嘗試
"typeRoots": [
"node_modules/@types" ]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.