2016-11-24 9 views
0

私はTypeScriptアプリケーションを持っています。 webpackでコンパイルしていますが、Windowsでは問題ありません。 MacOSでは、node_modulesフォルダのために何千ものエラーがあります。TypeScriptの重複問題はMacのみ(ウェブパックのコンパイル)

なぜ私はWindowsでコンパイルできるのですが、MacOSではコンパイルできないのか理解できますか?

私のパッケージのバージョンは、OS:TypeScript 2.1.1,Webpack 1.13.3と同じで、モジュールはyarn.lockの助けを借りて全く同じバージョンです。

ここtsconfig.json:ここ

{ 
    "compilerOptions": { 
     "target": "es5", 
     "module": "commonjs", 
     "experimentalDecorators": true, 
     "emitDecoratorMetadata": true 
    }, 
    "compileOnSave": false 
} 

webpack.config.js

ここ
var webpack = require('webpack'); 
var HtmlWebpackPlugin = require('html-webpack-plugin'); 

module.exports = { 
    entry: { 
     'app': [ 
      'core-js/client/shim.min.js', 
      'zone.js/dist/zone', 
      './src/app/main.ts' 
     ] 
    }, 
    output: { 
     path: './www', 
     filename: '[name].js' 
    }, 
    module: { 
     loaders: [ 
      {test: /\.component.ts$/, loader: 'ts!angular2-template'}, 
      {test: /\.ts$/, exclude: /\.component.ts$/, loader: 'ts'}, 
      {test: /\.html$/, loader: 'raw'} 
     ] 
    }, 
    resolve: { 
     extensions: ['', '.js', '.ts'] 
    }, 
    plugins: [ 
     new webpack.optimize.UglifyJsPlugin({ 
      compress: { 
       warnings: false 
      }, 
      output: { 
       comments: false 
      }, 
      minimize: true 
     }), 
     new HtmlWebpackPlugin({ 
      template: './src/index.html' 
     }), 
     new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /en-gb\.js|fr\.js/) 
    ] 
}; 

webpack出力の先頭(エラーの10300行があるので、数行):

ts-loader: Using [email protected] and /Users/yolo/Documents/app1/tsconfig.json 
Hash: 3b637fc56087f3ccacc8 
Version: webpack 1.13.3 
Time: 27898ms 
    Asset Size Chunks    Chunk Names 
    app.js 915 kB  0 [emitted] app 
index.html 1 kB   [emitted] 
    [0] multi app 52 bytes {0} [built] 
    [27] ./src/app/app.module.js 4.55 kB {0} [built] 
    [33] ./src/app/request/request.service.js 3.19 kB {0} [built] 
    [34] ./src/app/system/system.js 269 bytes {0} [built] 
    [63] ./src/app/app.component.js 1.19 kB {0} [built] 
    [64] ./src/app/rxjs-operators.js 347 bytes {0} [built] 
    [85] ./src/app/app.routing.js 1.4 kB {0} [built] 
    [86] ./src/app/login/login.component.js 8.95 kB {0} [built] 
    [87] ./src/app/navbar/navbar.service.js 4.25 kB {0} [built] 
    [88] ./src/app/account/account.service.js 1.98 kB {0} [built] 
    [89] ./src/app/location/location.service.js 2.56 kB {0} [built] 
    [90] ./src/app/storage/storage.service.js 6.8 kB {0} [built] 
    [91] ./src/app/version/version.service.js 1.4 kB {0} [built] 
    [92] ./src/app/download/download.service.js 1.41 kB {0} [built] 
    [93] ./src/app/page-dialog/page-dialog.service.js 2.93 kB {0} [built] 
    [94] ./src/app/pages/pages.service.js 9.54 kB {0} [built] 
[100] ./src/app/slideshow/slideshow.component.js 2.19 kB {0} [built] 
[101] ./src/app/logout/logout.component.js 2.27 kB {0} [built] 
[102] ./src/app/proceeded-pages/proceeded-pages.component.js 2.92 kB {0} [built] 
[103] ./src/app/pages/pages.component.js 3.38 kB {0} [built] 
[104] ./src/app/planning/planning.component.js 3.05 kB {0} [built] 
[105] ./src/app/planning/planning.service.js 4.04 kB {0} [built] 
[106] ./src/app/init/init.component.js 11.6 kB {0} [built] 
[107] ./src/app/navbar/navbar.component.js 2.54 kB {0} [built] 
[108] ./src/app/page/page.component.js 3.08 kB {0} [built] 
[109] ./src/app/page/page.js 122 bytes {0} [built] 
[110] ./src/app/login/login-form/login-form.component.js 2.87 kB {0} [built] 
[111] ./src/app/login/login.js 203 bytes {0} [built] 
[112] ./src/app/directives/c7z-container.directive.js 1.81 kB {0} [built] 
[113] ./src/app/directives/c7z-full-height.directive.js 1.61 kB {0} [built] 
[114] ./src/app/page-dialog/page-dialog.component.js 4.18 kB {0} [built] 
    + 84 hidden modules 

ERROR in /Users/yolo/Documents/app1/www/node_modules/zone.js/dist/zone.js.d.ts 
(122,11): error TS2451: Cannot redeclare block-scoped variable 'Zone'. 

ERROR in /Users/yolo/Documents/app1/www/node_modules/zone.js/dist/zone.js.d.ts 
(367,14): error TS2300: Duplicate identifier 'HasTaskState'. 

ERROR in /Users/yolo/Documents/app1/www/node_modules/zone.js/dist/zone.js.d.ts 
(376,14): error TS2300: Duplicate identifier 'TaskType'. 

ERROR in /Users/yolo/Documents/app1/www/node_modules/zone.js/dist/zone.js.d.ts 
(462,15): error TS2451: Cannot redeclare block-scoped variable 'Zone'. 

ERROR in /Users/yolo/Documents/app1/typings/globals/phonegap-plugin-push/index.d.ts 
(4,7): error TS2300: Duplicate identifier 'EventResponse'. 

ERROR in /Users/yolo/Documents/app1/typings/globals/phonegap-plugin-push/index.d.ts 
(190,3): error TS2374: Duplicate string index signature. 

ERROR in /Users/yolo/Documents/app1/typings/globals/phonegap-plugin-push/index.d.ts 
(250,3): error TS2374: Duplicate string index signature. 

ERROR in /Users/yolo/Documents/app1/typings/globals/node/index.d.ts 
(46,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'main' must be of type 'any', but here has type 'NodeModule'. 

ERROR in /Users/yolo/Documents/app1/typings/globals/node/index.d.ts 
(57,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'parent' must be of type 'any', but here has type 'NodeModule'. 

ERROR in /Users/yolo/Documents/app1/typings/globals/node/index.d.ts 
(58,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'children' must be of type 'any[]', but here has type 'NodeModule[]'. 

ERROR in /Users/yolo/Documents/app1/typings/globals/node/index.d.ts 
(78,6): error TS2300: Duplicate identifier 'BufferEncoding'. 

ERROR in /Users/yolo/Documents/app1/typings/globals/node/index.d.ts 
(227,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'errno' must be of type 'string', but here has type 'number'. 

ERROR in /Users/yolo/Documents/app1/typings/globals/node/index.d.ts 
(234,18): error TS2300: Duplicate identifier 'EventEmitter'. 

ERROR in /Users/yolo/Documents/app1/typings/globals/node/index.d.ts 
(522,26): error TS2300: Duplicate identifier 'Buffer'. 

ERROR in /Users/yolo/Documents/app1/typings/globals/node/index.d.ts 
(522,50): error TS2300: Duplicate identifier 'SlowBuffer'. 

ERROR in /Users/yolo/Documents/app1/typings/globals/node/index.d.ts 
(543,18): error TS2300: Duplicate identifier 'EventEmitter'. 

ERROR in /Users/yolo/Documents/app1/typings/globals/node/index.d.ts 
(543,18): error TS2415: Class 'EventEmitter' incorrectly extends base class 'NodeJS.EventEmitter'. 
    Types of property 'eventNames' are incompatible. 
    Type '() => (string | symbol)[]' is not assignable to type '() => string[]'. 
     Type '(string | symbol)[]' is not assignable to type 'string[]'. 
     Type 'string | symbol' is not assignable to type 'string'. 
      Type 'symbol' is not assignable to type 'string'. 

ERROR in /Users/yolo/Documents/app1/typings/globals/node/index.d.ts 
(654,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'httpVersionMajor' must be of type 'string', but here has type 'number'. 

ERROR in /Users/yolo/Documents/app1/typings/globals/node/index.d.ts 
(655,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'httpVersionMinor' must be of type 'string', but here has type 'number'. 

ERROR in /Users/yolo/Documents/app1/typings/globals/node/index.d.ts 
(656,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'connection' must be of type 'any', but here has type 'Socket'. 

ERROR in /Users/yolo/Documents/app1/typings/globals/node/index.d.ts 
(706,18): error TS2300: Duplicate identifier 'Agent'. 

ERROR in /Users/yolo/Documents/app1/typings/globals/node/index.d.ts 
(761,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'addressType' must be of type 'string', but here has type 'number | "udp4" | "udp6"'. 

ERROR in /Users/yolo/Documents/app1/typings/globals/node/index.d.ts 
(764,18): error TS2300: Duplicate identifier 'Worker'. 

ERROR in /Users/yolo/Documents/app1/typings/globals/node/index.d.ts 
(1485,18): error TS2300: Duplicate identifier 'Script'. 

ERROR in /Users/yolo/Documents/app1/typings/globals/node/index.d.ts 
(2016,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'type' must be of type 'string', but here has type '"udp4" | "udp6"'. 

ERROR in /Users/yolo/Documents/app1/typings/globals/node/index.d.ts 
(2432,22): error TS2451: Cannot redeclare block-scoped variable 'constants'. 

ERROR in /Users/yolo/Documents/app1/typings/globals/node/index.d.ts 
(2787,18): error TS2300: Duplicate identifier 'TLSSocket'. 

ERROR in /Users/yolo/Documents/app1/typings/globals/node/index.d.ts 
(2984,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'pfx' must be of type 'any', but here has type 'string | Buffer[]'. 

ERROR in /Users/yolo/Documents/app1/typings/globals/node/index.d.ts 
(2985,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'key' must be of type 'any', but here has type 'string | any[] | string[] | Buffer'. 

ERROR in /Users/yolo/Documents/app1/typings/globals/node/index.d.ts 
(2987,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'cert' must be of type 'any', but here has type 'string | string[] | Buffer | Buffer[]'. 

ERROR in /Users/yolo/Documents/app1/typings/globals/node/index.d.ts 
(2988,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'ca' must be of type 'any', but here has type 'string | string[] | Buffer | Buffer[]'. 

ERROR in /Users/yolo/Documents/app1/typings/globals/node/index.d.ts 
(2989,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'crl' must be of type 'any', but here has type 'string | string[]'. 

ERROR in /Users/yolo/Documents/app1/typings/globals/node/index.d.ts 
(2991,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'honorCipherOrder' must be of type 'any', but here has type 'boolean'. 

ERROR in /Users/yolo/Documents/app1/typings/globals/node/index.d.ts 
(2994,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'NPNProtocols' must be of type 'any', but here has type 'string[] | Buffer'. 

ERROR in /Users/yolo/Documents/app1/typings/globals/node/index.d.ts 
(3011,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'key' must be of type 'string | Buffer', but here has type 'string | string[] | Buffer | Buffer[]'. 

ERROR in /Users/yolo/Documents/app1/typings/globals/node/index.d.ts 
(3013,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'cert' must be of type 'string | Buffer', but here has type 'string | string[] | Buffer | Buffer[]'. 

ERROR in /Users/yolo/Documents/app1/typings/globals/node/index.d.ts 
(3014,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'ca' must be of type '(string | Buffer)[]', but here has type 'string | Buffer | (string | Buffer)[]'. 

答えて

0

私は確信が持てないエラーログファイルの詳細については、webpackは/node_modulestypingsのtypescript定義をコンパイルしているようです。重複した識別子に関するエラーがあるので、いくつかの定義がnode_modulestypingsの両方にあると考えることができます。 node_modulesの定義をコンパイルしないようにして、それが違いを生むかどうか試してみてください。そのためには、tsconfig.jsonに以下を追加します。

"compilerOptions": { 
    ... 
}, 
"exclude": [ 
    "node_modules" 
] 

繰り返しますが、私はこれが問題であることを確実に言うことはできませんが、それは推測のより多くのです。また、なぜこれがWindowsではなくMac上で動作するのかわかりません。

+0

答えをいただきありがとうございます、私は、あなたの変更を加えて、私のアプリを再インストールして、すべてが問題ありません...何が起こったのか分かりません!しかし、ありがとう。 Windows上でなぜ私は問題がないのか不思議に思うだけです –

関連する問題