繁体   English   中英

TypeDoc找不到Angular2模块

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM