首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >仅在Mac上发布TypeScript复制问题(webpack编译)

仅在Mac上发布TypeScript复制问题(webpack编译)
EN

Stack Overflow用户
提问于 2016-11-24 16:15:35
回答 1查看 187关注 0票数 0

我有一个TypeScript应用程序。我和webpack一起编译,在Windows下我没有任何问题。在MacOS下,由于node_modules文件夹,我有数千个错误。

你能帮我理解为什么我可以在Windows上编译,而不能在MacOS上编译吗?

我的包版本在两个操作系统上都是相同的:TypeScript 2.1.1Webpack 1.13.3和模块在yarn.lock的帮助下具有完全相同的版本。

在这里,tsconfig.json

代码语言:javascript
复制
{
    "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "experimentalDecorators": true,
        "emitDecoratorMetadata": true
    },
    "compileOnSave": false
}

在这里,webpack.config.js

代码语言:javascript
复制
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行错误):

代码语言:javascript
复制
ts-loader: Using typescript@2.1.1 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)[]'.
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-11-24 17:16:45

我不能肯定地说,因为我需要更多的错误日志文件,但是webpack似乎正在编译来自/node_modulestypings以及您的应用程序的类型记录定义。由于存在关于重复标识符的错误,因此我认为在node_modulestypings中都找到了一些定义。您可以尝试将node_modules定义排除在编译之外,看看这是否有区别。为此,请将以下内容添加到tsconfig.json

代码语言:javascript
复制
"compilerOptions": {
    ...
},
"exclude": [
    "node_modules"
]

再说一次,我不能肯定这就是问题所在,更多的是猜测。而且,我也不知道为什么这将在windows上工作,而在Mac上不起作用。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40790897

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档