简体   繁体   English

TypeDoc找不到Angular2模块

[英]TypeDoc can not find Angular2 modules

I am trying to generate doc files by using TypeDoc. 我正在尝试使用TypeDoc生成doc文件。 When I run TypeDoc with the follwing command: 当我使用以下命令运行TypeDoc时:

/node_modules/.bin/typedoc --module system --target ES5 --exclude *.spec.ts* --experimentalDecorators --out typedoc app/ --ignoreCompilerErrors

It gives as output: 它给出作为输出:

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 tsconfig.json

{
  "compilerOptions": {
    "target": "ES5",
    "module": "system",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false
  },
  "exclude": [
    "node_modules"
  ]
}

Is there some kind of parameter I am missing here to include the libs or .d.ts. 是否有某种我缺少的参数包含libs或.d.ts. files? 文件?

我尝试了commonjs模块,它起作用了。

typedoc --experimentalDecorators --target 'es5' --module 'commonjs' --out doc-destination/ src/

I use typedoc with angular2 application. 我在angular2应用程序中使用typedoc。 Although I run it through gulp-typedoc the passed parameters should be the same. 尽管我通过gulp-typedoc运行它,但传递的参数应该相同。 The following gulp task does the job for me: 以下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,
        }));
});

Hope this helps. 希望这可以帮助。

Add the configuration for type definition files in your tsconfig.json and try 在tsconfig.json中添加类型定义文件的配置,然后尝试

"typeRoots": [
  "node_modules/@types" ]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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