Angular 2 npm start不会忽略node_modules

时间:2016-05-10 20:42:40

标签: npm angular

这是我的tsconfig.json文件的样子:

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false,
    "suppressImplicitAnyIndexErrors": true
  },
  "exclude": [
    "node_modules",
    "typings/main",
    "typings/main.d.ts"
  ]
}

每次运行npm start时,这大约是我的控制台打印的5%。其余的输出类似。它基本上遍历每个@angular模块。

16.05.10 22:47:13 304 GET /node_modules/@angular/router-deprecated/core_private.js
[1] 16.05.10 22:47:13 304 GET /node_modules/@angular/router-deprecated/src/lifecycle/lifecycle_annotations_impl.js
[1] 16.05.10 22:47:13 304 GET /node_modules/@angular/common/src/facade/lang.js
[1] 16.05.10 22:47:13 304 GET /node_modules/@angular/common/src/facade/async.js
[1] 16.05.10 22:47:13 304 GET /node_modules/@angular/common/src/pipes/invalid_pipe_argument_exception.js
[1] 16.05.10 22:47:13 304 GET /node_modules/@angular/common/src/facade/intl.js
[1] 16.05.10 22:47:13 304 GET /node_modules/@angular/common/src/facade/collection.js
[1] 16.05.10 22:47:13 304 GET /node_modules/@angular/common/src/facade/exceptions.js
[1] 16.05.10 22:47:13 304 GET /node_modules/@angular/common/src/facade/promise.js
[1] 16.05.10 22:47:13 304 GET /node_modules/@angular/common/src/forms/directives/shared.js
[1] 16.05.10 22:47:13 304 GET /node_modules/@angular/common/src/forms/directives/number_value_accessor.js
[1] 16.05.10 22:47:13 304 GET /node_modules/@angular/compiler/src/facade/lang.js
[1] 16.05.10 22:47:13 304 GET /node_modules/@angular/compiler/src/template_parser.js
[1] 16.05.10 22:47:13 304 GET /node_modules/@angular/compiler/src/config.js
[1] 16.05.10 22:47:13 304 GET /node_modules/@angular/compiler/src/compile_metadata.js
[1] 16.05.10 22:47:13 304 GET /node_modules/@angular/compiler/src/offline_compiler.js
[1] 16.05.10 22:47:13 304 GET /node_modules/@angular/compiler/src/runtime_compiler.js
[1] 16.05.10 22:47:13 304 GET /node_modules/@angular/compiler/src/url_resolver.js
[1] 16.05.10 22:47:13 304 GET /node_modules/@angular/compiler/src/view_resolver.js
[1] 16.05.10 22:47:13 304 GET /node_modules/@angular/compiler/src/directive_resolver.js
[1] 16.05.10 22:47:13 304 GET /node_modules/@angular/compiler/src/pipe_resolver.js
[1] 16.05.10 22:47:13 304 GET /node_modules/@angular/compiler/src/html_parser.js
[1] 16.05.10 22:47:13 304 GET /node_modules/@angular/compiler/src/directive_normalizer.js
[1] 16.05.10 22:47:13 304 GET /node_modules/@angular/compiler/src/metadata_resolver.js

即使我选择排除node_modules,每次运行npm start时都会扫描它们(大约需要30秒......)。这发生在我更新到beta rc.1之后。有没有人有解决方法如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

这是正确的和预期的行为。您的Web服务器只显示它所服务的文件,因为浏览器已请求它们。

tsconfig.json中,您告诉TypeScript编译器忽略编译中的node_modules。