【问题标题】:Angular 2 electron project compiling is having problemsAngular 2 电子项目编译有问题
【发布时间】:2017-12-27 10:31:41
【问题描述】:

我回到了一个我有一段时间没有处理过的项目,在一台新机器上,我在编译和运行它时遇到了问题。

这是我的配置:

节点版本 v6.11.1 NPM 版本 3.10.10

这是我的 package.json 文件:

{
  "name": "ConnectToolkit",
  "version": "0.0.1",
  "description": "my proj",
  "main": "main.js",
  "scripts": {
    "start": "electron main.js",
    "build": "webpack --progress --profile --colors --display-error-details --display-cached",
    "watch": "webpack --watch --progress --profile --colors --display-error-details --display-cached",
    "distribute": "electron-packager . Electrogram --platform=darwin --arch=x64 --out=releases/ --overwrite --icon=src/assets/images/electrogram  --asar"
  },
  "author": "Andy Armstrong",
  "license": "See Licence.txt ",
  "devDependencies": {
    "@types/core-js": "^0.9.34",
    "@types/hammerjs": "^2.0.33",
    "@types/jasmine": "^2.5.37",
    "@types/node": "^6.0.46",
    "@types/selenium-webdriver": "^2.53.33",
    "@types/webpack": "^1.12.35",
    "@types/zone.js": "0.0.27",
    "css-loader": "^0.25.0",
    "electron": "^1.4.5",
    "electron-packager": "^8.2.0",
    "electron-prebuilt": "^1.4.5",
    "electron-rebuild": "^1.5.11",
    "electron-reload": "^1.0.2",
    "file-loader": "^0.9.0",
    "json-loader": "^0.5.4",
    "raw-loader": "^0.5.1",
    "ts-loader": "^1.0.0",
    "typescript": "^2.0.6",
    "uglify-js": "^2.7.4",
    "url-loader": "^0.5.7",
    "webpack": "^1.13.3"
  },
  "dependencies": {
    "@angular/common": "^2.1.2",
    "@angular/compiler": "^2.1.2",
    "@angular/core": "^2.1.2",
    "@angular/platform-browser": "^2.1.2",
    "@angular/platform-browser-dynamic": "^2.1.2",
    "@angular/router": "^3.1.2",
    "electron-window-state": "^3.1.0",
    "es6-shim": "^0.35.1",
    "ftp": "^0.3.10",
    "jquery": "^3.1.1",
    "material-design-lite": "^1.2.1",
    "ng2-popover": "0.0.11",
    "node-persist": "^2.0.7",
    "open": "0.0.5",
    "reflect-metadata": "^0.1.8",
    "rxjs": "5.0.0-beta.12",
    "ssh2": "^0.5.4",
    "systemjs": "^0.19.40",
    "xml2js": "^0.4.17",
    "zone.js": "^0.6.26"
  }
}

当我运行 npm install 时,我得到以下输出:

npm i
npm WARN deprecated ng2-popover@0.0.11: name updated to match new angular versions. install ngx-popover instead
npm WARN deprecated electron-prebuilt@1.4.13: electron-prebuilt has been renamed to electron. For more details, see http://electron.atom.io/blog/2016/08/16/npm-install-electron
npm WARN deprecated fs-promise@2.0.3: Use mz or fs-extra^3.0 with Promise Support
npm WARN prefer global node-gyp@3.6.2 should be installed with -g

> fsevents@1.1.2 install /Users/andy.armstronguk.ibm.com/Documents/Personal/ConnectToolkit/node_modules/fsevents
> node install

[fsevents] Success: "/Users/andy.armstronguk.ibm.com/Documents/Personal/ConnectToolkit/node_modules/fsevents/lib/binding/Release/node-v48-darwin-x64/fse.node" already installed
Pass --update-binary to reinstall or --build-from-source to recompile

> electron@1.6.11 postinstall /Users/andy.armstronguk.ibm.com/Documents/Personal/ConnectToolkit/node_modules/electron
> node install.js


> electron-prebuilt@1.4.13 postinstall /Users/andy.armstronguk.ibm.com/Documents/Personal/ConnectToolkit/node_modules/electron-prebuilt
> node install.js

ConnectToolkit@0.0.1 /Users/andy.armstronguk.ibm.com/Documents/Personal/ConnectToolkit
├── @angular/common@2.4.10 
├── @angular/compiler@2.4.10 
├── @angular/core@2.4.10 
├── @angular/platform-browser@2.4.10 
├── @angular/platform-browser-dynamic@2.4.10 
├── @angular/router@3.4.10 
├── @types/core-js@0.9.42 
├── @types/hammerjs@2.0.34 
├── @types/jasmine@2.5.53 
├── @types/node@6.0.84 
├── @types/selenium-webdriver@2.53.42 
├─┬ @types/webpack@1.12.36 
│ └─┬ @types/uglify-js@2.6.29 
│   └── @types/source-map@0.5.0 
├── @types/zone.js@0.0.27 
├─┬ css-loader@0.25.0 
│ ├─┬ babel-code-frame@6.22.0 
│ │ ├─┬ chalk@1.1.3 
│ │ │ ├── ansi-styles@2.2.1 
│ │ │ ├── escape-string-regexp@1.0.5 
│ │ │ ├─┬ has-ansi@2.0.0 
│ │ │ │ └── ansi-regex@2.1.1 
│ │ │ ├── strip-ansi@3.0.1 
│ │ │ └── supports-color@2.0.0 
│REMOVED SOME DUE TO SIZE!
│   │   ├─┬ rimraf@2.6.1 
│   │   │ └─┬ glob@7.1.2 
│   │   │   ├── fs.realpath@1.0.0 
│   │   │   ├── inflight@1.0.6 
│   │   │   ├─┬ minimatch@3.0.4 
│   REMOVE MORE DUE TO SIZE!
│ │ ├── async@0.2.10 
│ │ └─┬ yargs@3.10.0 
│ │   ├── camelcase@1.2.1 
│ │   └── cliui@2.1.0 
│ ├─┬ watchpack@0.2.9 
│ │ └── async@0.9.2 
│ └─┬ webpack-core@0.6.9 
│   └─┬ source-map@0.4.4 
│     └── amdefine@1.0.1 
├─┬ xml2js@0.4.17 
│ ├── sax@1.2.4 
│ └─┬ xmlbuilder@4.2.1 
│   └── lodash@4.17.4 
└── UNMET PEER DEPENDENCY zone.js@0.6.26

npm WARN @angular/core@2.4.10 requires a peer of rxjs@^5.0.1 but none was installed.
npm WARN @angular/core@2.4.10 requires a peer of zone.js@^0.7.2 but none was installed.
npm WARN @angular/router@3.4.10 requires a peer of rxjs@^5.0.1 but none was installed.
npm WARN ConnectToolkit@0.0.1 No repository field.
npm WARN ConnectToolkit@0.0.1 license should be a valid SPDX license expression

这看起来不太好:

reflect-metadata@0.1.10 
├─┬ UNMET PEER DEPENDENCY rxjs@5.0.0-beta.12

还有└── UNMET PEER DEPENDENCY zone.js@0.6.26 以及输出底部的各种消息。不知道如何解决这些问题。

如果我忽略这些消息 - 并继续尝试通过运行以下命令编译项目:npm run build 执行命令:webpack --progress --profile --colors --display-error-details --display-cached

我收到以下错误:

npm run build

> ConnectToolkit@0.0.1 build /Users/andy.armstronguk.ibm.com/Documents/Personal/ConnectToolkit
> webpack --progress --profile --colors --display-error-details --display-cached

 27% 2/7 build modulests-loader: Using typescript@2.4.2 and /Users/andy.armstronguk.ibm.com/Documents/Personal/ConnectToolkit/tsconfig.json
5916ms build modules      
14ms seal
21ms optimize
40ms hashing
58ms create chunk assets
19ms additional chunk assets
2273ms optimize chunk assets
617ms optimize assets
73ms emit
Hash: 919b8c47d992c219c128
Version: webpack 1.15.0
Time: 9049ms
          Asset    Size  Chunks             Chunk Names
    @angular.js  767 kB       0  [emitted]  @angular
         app.js  2.9 MB       1  [emitted]  app
      common.js  145 kB       2  [emitted]  common
@angular.js.map  919 kB       0  [emitted]  @angular
     app.js.map  3.5 MB       1  [emitted]  app
  common.js.map  167 kB       2  [emitted]  common
   [0] multi @angular 52 bytes {0} [built]
       factory:0ms building:1ms = 1ms
   [0] multi common 28 bytes {2} [built]
       factory:1ms building:0ms = 1ms
 [346] external "events" 42 bytes {0} [not cacheable]
       ... -> factory:0ms building:1ms
 [347] external "fs" 42 bytes {0} [not cacheable]
       ... -> factory:1ms building:0ms
 [348] external "timers" 42 bytes {0} [not cacheable]
       ... -> factory:1ms building:0ms
 [349] external "crypto" 42 bytes {0} [not cacheable]
       ... -> factory:1ms building:0ms
 [350] external "_http_client" 42 bytes {0} [not cacheable] [optional]
       ... -> factory:1ms building:0ms
 [367] external "tls" 42 bytes {1} [not cacheable]
       ... -> factory:1ms building:0ms
 [368] external "zlib" 42 bytes {1} [not cacheable]
       ... -> factory:1ms building:0ms
 [369] external "net" 42 bytes {1} [not cacheable]
       ... -> factory:1ms building:0ms
 [370] external "util" 42 bytes {1} [not cacheable]
       ... -> factory:1ms building:0ms
 [372] external "stream" 42 bytes {1} [not cacheable]
       ... -> factory:0ms building:0ms
 [376] external "buffer" 42 bytes {1} [not cacheable]
       ... -> factory:0ms building:0ms
 [386] external "readline" 42 bytes {1} [not cacheable]
       ... -> factory:0ms building:0ms
 [391] external "path" 42 bytes {1} [not cacheable]
       ... -> factory:0ms building:0ms
 [402] external "electron" 42 bytes {1} [not cacheable]
       ... -> factory:4ms building:0ms
 [404] external "child_process" 42 bytes {1} [not cacheable]
       ... -> factory:0ms building:0ms
 [412] external "string_decoder" 42 bytes {1} [not cacheable]
       ... -> factory:0ms building:0ms
    + 579 hidden modules

ERROR in /Users/andy.armstronguk.ibm.com/Documents/Personal/ConnectToolkit/node_modules/@angular/compiler/src/output/output_ast.d.ts
(433,63): error TS2304: Cannot find name 'Set'.

ERROR in /Users/andy.armstronguk.ibm.com/Documents/Personal/ConnectToolkit/node_modules/@angular/compiler/src/aot/compiler.d.ts
(44,32): error TS2304: Cannot find name 'Map'.

ERROR in /Users/andy.armstronguk.ibm.com/Documents/Personal/ConnectToolkit/node_modules/@angular/compiler/src/compile_metadata.d.ts
(342,20): error TS2304: Cannot find name 'Set'.

ERROR in /Users/andy.armstronguk.ibm.com/Documents/Personal/ConnectToolkit/node_modules/@angular/compiler/src/compile_metadata.d.ts
(344,28): error TS2304: Cannot find name 'Set'.

ERROR in /Users/andy.armstronguk.ibm.com/Documents/Personal/ConnectToolkit/node_modules/@angular/compiler/src/compile_metadata.d.ts
(346,15): error TS2304: Cannot find name 'Set'.

ERROR in /Users/andy.armstronguk.ibm.com/Documents/Personal/ConnectToolkit/node_modules/@angular/compiler/src/compile_metadata.d.ts
(348,23): error TS2304: Cannot find name 'Set'.

ERROR in /Users/andy.armstronguk.ibm.com/Documents/Personal/ConnectToolkit/node_modules/@angular/compiler/src/compile_metadata.d.ts
(350,17): error TS2304: Cannot find name 'Set'.

ERROR in /Users/andy.armstronguk.ibm.com/Documents/Personal/ConnectToolkit/node_modules/@angular/compiler/src/compile_metadata.d.ts
(352,25): error TS2304: Cannot find name 'Set'.

ERROR in /Users/andy.armstronguk.ibm.com/Documents/Personal/ConnectToolkit/node_modules/@angular/platform-browser/src/dom/shared_styles_host.d.ts
(11,30): error TS2304: Cannot find name 'Set'.

ERROR in /Users/andy.armstronguk.ibm.com/Documents/Personal/ConnectToolkit/node_modules/@angular/platform-browser/src/dom/shared_styles_host.d.ts
(22,30): error TS2304: Cannot find name 'Set'.

ERROR in /Users/andy.armstronguk.ibm.com/Documents/Personal/ConnectToolkit/node_modules/@angular/platform-browser/src/dom/dom_renderer.d.ts
(22,37): error TS2304: Cannot find name 'Map'.

ERROR in /Users/andy.armstronguk.ibm.com/Documents/Personal/ConnectToolkit/node_modules/@angular/common/src/directives/ng_class.d.ts
(48,34): error TS2304: Cannot find name 'Set'.

ERROR in /Users/andy.armstronguk.ibm.com/Documents/Personal/ConnectToolkit/node_modules/@angular/platform-browser/src/dom/dom_adapter.d.ts
(97,42): error TS2304: Cannot find name 'Map'.

ERROR in /Users/andy.armstronguk.ibm.com/Documents/Personal/ConnectToolkit/node_modules/@angular/platform-browser/src/browser/browser_adapter.d.ts
(79,33): error TS2304: Cannot find name 'Map'.

ERROR in /Users/andy.armstronguk.ibm.com/Documents/Personal/ConnectToolkit/node_modules/rxjs/operator/toPromise.d.ts
(7,59): error TS2693: 'Promise' only refers to a type, but is being used as a value here.

ERROR in /Users/andy.armstronguk.ibm.com/Documents/Personal/ConnectToolkit/node_modules/rxjs/operator/toPromise.d.ts
(10,26): error TS2693: 'Promise' only refers to a type, but is being used as a value here.

ERROR in /Users/andy.armstronguk.ibm.com/Documents/Personal/ConnectToolkit/node_modules/rxjs/observable/dom/WebSocketSubject.d.ts
(23,22): error TS2415: Class 'WebSocketSubject<T>' incorrectly extends base class 'AnonymousSubject<T>'.
  Types of property 'lift' are incompatible.
    Type '<R>(operator: Operator<T, R>) => WebSocketSubject<R>' is not assignable to type '<T, R>(operator: Operator<T, R>) => Observable<T>'.
      Type 'WebSocketSubject<R>' is not assignable to type 'Observable<T>'.
        Types of property 'operator' are incompatible.
          Type 'Operator<any, R>' is not assignable to type 'Operator<any, T>'.
            Type 'R' is not assignable to type 'T'.

ERROR in /Users/andy.armstronguk.ibm.com/Documents/Personal/ConnectToolkit/node_modules/rxjs/Observable.d.ts
(66,60): error TS2693: 'Promise' only refers to a type, but is being used as a value here.

ERROR in /Users/andy.armstronguk.ibm.com/Documents/Personal/ConnectToolkit/node_modules/rxjs/Subject.d.ts
(16,22): error TS2415: Class 'Subject<T>' incorrectly extends base class 'Observable<T>'.
  Types of property 'lift' are incompatible.
    Type '<T, R>(operator: Operator<T, R>) => Observable<T>' is not assignable to type '<R>(operator: Operator<T, R>) => Observable<R>'.
      Type 'Observable<T>' is not assignable to type 'Observable<R>'.
        Type 'T' is not assignable to type 'R'.

ERROR in /Users/andy.armstronguk.ibm.com/Documents/Personal/ConnectToolkit/node_modules/@angular/core/src/change_detection/differs/default_keyvalue_differ.d.ts
(24,15): error TS2304: Cannot find name 'Map'.

ERROR in /Users/andy.armstronguk.ibm.com/Documents/Personal/ConnectToolkit/node_modules/@angular/core/src/change_detection/differs/default_keyvalue_differ.d.ts
(28,16): error TS2304: Cannot find name 'Map'.

ERROR in /Users/andy.armstronguk.ibm.com/Documents/Personal/ConnectToolkit/node_modules/@angular/core/src/facade/lang.d.ts
(12,17): error TS2304: Cannot find name 'Map'.

ERROR in /Users/andy.armstronguk.ibm.com/Documents/Personal/ConnectToolkit/node_modules/@angular/core/src/facade/lang.d.ts
(13,17): error TS2304: Cannot find name 'Set'.

ERROR in /Users/andy.armstronguk.ibm.com/Documents/Personal/ConnectToolkit/node_modules/@angular/core/src/di/reflective_provider.d.ts
(87,123): error TS2304: Cannot find name 'Map'.

ERROR in /Users/andy.armstronguk.ibm.com/Documents/Personal/ConnectToolkit/node_modules/@angular/core/src/di/reflective_provider.d.ts
(87,165): error TS2304: Cannot find name 'Map'.

ERROR in ./src/app/settings/settings.component.ts
(5,19): error TS2304: Cannot find name 'require'.

ERROR in ./src/app/settings/settings.component.ts
(6,14): error TS2304: Cannot find name 'require'.

ERROR in ./src/app/settings/settings.component.ts
(13,15): error TS2304: Cannot find name 'require'.

ERROR in ./src/app/settings/settings.component.ts
(14,15): error TS2304: Cannot find name 'require'.

ERROR in ./src/app/services/ssh-service/ssh.service.ts
(1,12): error TS2304: Cannot find name 'require'.

ERROR in ./src/app/services/ssh-service/ssh.service.ts
(2,26): error TS2304: Cannot find name 'require'.

ERROR in ./src/app/services/ftp-service/ftp.service.ts
(1,16): error TS2304: Cannot find name 'require'.

ERROR in ./src/app/services/ftp-service/ftp.service.ts
(2,12): error TS2304: Cannot find name 'require'.

ERROR in ./src/app/services/ftp-service/ftp.service.ts
(3,18): error TS2304: Cannot find name 'require'.

ERROR in ./src/app/services/files-service/files.service.ts
(1,15): error TS2304: Cannot find name 'require'.

ERROR in ./src/app/services/files-service/files.service.ts
(2,10): error TS2304: Cannot find name 'require'.

ERROR in /Users/andy.armstronguk.ibm.com/Documents/Personal/ConnectToolkit/src/app/services/canvas/canvasService.ts
(2,19): error TS2304: Cannot find name 'require'.

ERROR in ./src/app/services/api-service/api.service.ts
(97,16): error TS2304: Cannot find name 'require'.

ERROR in ./src/app/services/api-service/api.service.ts
(98,20): error TS2304: Cannot find name 'require'.

ERROR in ./src/app/server-details/server.details.component.ts
(8,13): error TS2304: Cannot find name 'require'.

ERROR in ./src/app/server-details/server.details.component.ts
(9,13): error TS2304: Cannot find name 'require'.

ERROR in ./src/app/server-browser/server.browser.component.ts
(4,12): error TS2304: Cannot find name 'require'.

ERROR in ./src/app/server-browser/server.browser.component.ts
(6,19): error TS2304: Cannot find name 'require'.

ERROR in ./src/app/server-browser/server.browser.component.ts
(7,14): error TS2304: Cannot find name 'require'.

ERROR in ./src/app/server-browser/server.browser.component.ts
(10,17): error TS2304: Cannot find name 'require'.

ERROR in ./src/app/server-browser/server.browser.component.ts
(14,15): error TS2304: Cannot find name 'require'.

ERROR in ./src/app/server-browser/server.browser.component.ts
(15,15): error TS2304: Cannot find name 'require'.

ERROR in ./src/app/page-1/page.1.component.ts
(5,15): error TS2304: Cannot find name 'require'.

ERROR in ./src/app/page-1/page.1.component.ts
(6,15): error TS2304: Cannot find name 'require'.

ERROR in ./src/app/api-list/api.list.component.ts
(6,13): error TS2304: Cannot find name 'require'.

ERROR in ./src/app/api-list/api.list.component.ts
(7,13): error TS2304: Cannot find name 'require'.

ERROR in ./src/app/api-detail/api.detail.component.ts
(8,13): error TS2304: Cannot find name 'require'.

ERROR in ./src/app/api-detail/api.detail.component.ts
(9,13): error TS2304: Cannot find name 'require'.

ERROR in ./src/app/api-browser/api.browser.component.ts
(12,13): error TS2304: Cannot find name 'require'.

ERROR in ./src/app/api-browser/api.browser.component.ts
(13,13): error TS2304: Cannot find name 'require'.

ERROR in ./src/app/api-browser/api.browser.component.ts
(77,17): error TS2304: Cannot find name 'require'.

ERROR in ./src/app/app.component.ts
(6,15): error TS2304: Cannot find name 'require'.

ERROR in ./src/app/app.component.ts
(7,15): error TS2304: Cannot find name 'require'.

ERROR in /Users/andy.armstronguk.ibm.com/Documents/Personal/ConnectToolkit/src/customDefinitions.d.ts
(1,15): error TS2300: Duplicate identifier 'Notification'.

ERROR in /Users/andy.armstronguk.ibm.com/Documents/Personal/ConnectToolkit/tsconfig.json
error TS2688: Cannot find type definition file for 'core-js'.

ERROR in /Users/andy.armstronguk.ibm.com/Documents/Personal/ConnectToolkit/tsconfig.json
error TS2688: Cannot find type definition file for 'hammerjs'.

ERROR in /Users/andy.armstronguk.ibm.com/Documents/Personal/ConnectToolkit/tsconfig.json
error TS2688: Cannot find type definition file for 'jasmine'.

ERROR in /Users/andy.armstronguk.ibm.com/Documents/Personal/ConnectToolkit/tsconfig.json
error TS2688: Cannot find type definition file for 'node'.

ERROR in /Users/andy.armstronguk.ibm.com/Documents/Personal/ConnectToolkit/tsconfig.json
error TS2688: Cannot find type definition file for 'selenium-webdriver'.

ERROR in /Users/andy.armstronguk.ibm.com/Documents/Personal/ConnectToolkit/tsconfig.json
error TS2688: Cannot find type definition file for 'source-map'.

ERROR in /Users/andy.armstronguk.ibm.com/Documents/Personal/ConnectToolkit/tsconfig.json
error TS2688: Cannot find type definition file for 'uglify-js'.

ERROR in /Users/andy.armstronguk.ibm.com/Documents/Personal/ConnectToolkit/tsconfig.json
error TS2688: Cannot find type definition file for 'webpack'.

ERROR in /Users/andy.armstronguk.ibm.com/Documents/Personal/ConnectToolkit/tsconfig.json
error TS2688: Cannot find type definition file for 'zone.js'.

你可以清楚地看到 - 这可能是一个依赖错误,但这曾经与这个 package.json 一起工作......所以这可能与正在使用的不同版本的 npm / node 有关。

无论哪种方式,请提供帮助,以便我可以进行干净的编译并再次运行我的项目!

----- 更新:--------

我已经运行 npm-check-updates - 并更新了所有建议的 package.json 依赖项:

 npm-check-updates -u
[INFO]: You can also use ncu as an alias
Using /Users/andy.armstronguk.ibm.com/Documents/Personal/ConnectToolkit/package.json
⸨░░░░░░░░░░░░░░░░░░⸩ ⠼ :
 @angular/common                           ^2.1.2  →    ^4.3.1 
 @angular/compiler                         ^2.1.2  →    ^4.3.1 
 @angular/core                             ^2.1.2  →    ^4.3.1 
 @angular/platform-browser                 ^2.1.2  →    ^4.3.1 
 @angular/platform-browser-dynamic         ^2.1.2  →    ^4.3.1 
 @angular/router                           ^3.1.2  →    ^4.3.1 
 electron-window-state                     ^3.1.0  →    ^4.1.1 
 ng2-popover                               0.0.11  →    0.0.14 
 rxjs                               5.0.0-beta.12  →     5.4.2 
 systemjs                                ^0.19.40  →  ^0.20.15 
 zone.js                                  ^0.6.26  →   ^0.8.14 
 @types/node                              ^6.0.46  →   ^8.0.14 
 @types/selenium-webdriver               ^2.53.33  →    ^3.0.4 
 @types/webpack                          ^1.12.35  →    ^3.0.4 
 @types/zone.js                            0.0.27  →    0.5.12 
 css-loader                               ^0.25.0  →   ^0.28.4 
 file-loader                               ^0.9.0  →   ^0.11.2 
 ts-loader                                 ^1.0.0  →    ^2.3.1 
 uglify-js                                 ^2.7.4  →   ^3.0.25 
 webpack                                  ^1.13.3  →    ^3.3.0 

然后我运行npm run build,结果是:

npm run build

> ConnectToolkit@0.0.1 build /Users/andy.armstronguk.ibm.com/Documents/Personal/ConnectToolkit
> webpack --progress --profile --colors --display-error-details --display-cached

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration has an unknown property 'debug'. These properties are valid:
   object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry, externals?, loader?, module?, name?, node?, output?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, stats?, target?, watch?, watchOptions? }
   The 'debug' property was removed in webpack 2.
   Loaders should be updated to allow passing this option via loader options in module.rules.
   Until loaders are updated one can use the LoaderOptionsPlugin to switch loaders into debug mode:
   plugins: [
     new webpack.LoaderOptionsPlugin({
       debug: true
     })
   ]
 - configuration.resolve.extensions[0] should not be empty.

这表明 webpack.config.js 的语法已过时 - 请您帮我更新一下:

var path = require('path');
var webpack = require('webpack');
var CommonsChunkPlugin = webpack.optimize.CommonsChunkPlugin;

module.exports = {
  devtool: 'source-map',
  debug: true,

  entry: {
    '@angular': [
      'rxjs',
      'reflect-metadata',
      'zone.js'
    ],
    'common': ['es6-shim'],
    'app': './src/app/app.ts'
  },

  output: {
    path: __dirname + '/build/',
    publicPath: 'build/',
    filename: '[name].js',
    sourceMapFilename: '[name].js.map',
    chunkFilename: '[id].chunk.js'
  },

  resolve: {
    extensions: ['','.ts','.js','.json', '.css', '.html']
  },

  module: {
    loaders: [
      {
        test: /\.ts$/,
        loader: 'ts',
        exclude: [ /node_modules/, /releases/ ]
      },
      {
        test: /\.json$/,
        loader: 'json'
      },
      {
        test: /\.(css|html)$/,
        loader: 'raw'
      },
      {
        test: /\.(png|jpg)$/,
        loader: 'url?limit=10000'
      }
    ]
  },

  plugins: [
    new CommonsChunkPlugin({ names: ['@angular', 'common'], minChunks: Infinity })
  ],
  target:'electron-renderer'
};

【问题讨论】:

    标签: javascript angularjs node.js webpack electron


    【解决方案1】:

    使用此命令 npm-check-updates 将软件包更新到最新版本。尝试下载 Typescript 并从此链接 https://www.typescriptlang.org/index.html#download-links 安装。 安装时关闭VS

    【讨论】:

    • 嗨。谢谢 - 我已经这样做了,并用下一个障碍更新了我上面的问题 - 请帮我修复 webpack.config.js
    【解决方案2】:

    尝试更改 webpack.config.js:

    并从解析中删除空字符串

     resolve: {
        extensions: ['.ts','.js','.json', '.css', '.html']
      },
    
    
     plugins: [
               new webpack.ContextReplacementPlugin(
                // The (\\|\/) piece accounts for path separators in *nix and Windows
                 /angular(\\|\/)core(\\|\/)@angular/,
                helpers.root('./src'), // location of your src
                {} // a map of your routes
            ),
    
    new webpack.LoaderOptionsPlugin({ 
    options : { 
              htmlLoader : { 
                  minimize : false 
                       } 
        }
      }) 
    
    
    ]
    

    【讨论】:

    • 这看起来像文件的一个片段 - 整个文件会是什么样子,将其粘贴到 webpack.config.js 中会导致它在第 3 行抱怨“,”!
    • 在扩展中删除空字符串
    • 对不起,我不认为你理解我 - 你在上面粘贴的 - 这意味着 webpack.config.js 的全部内容吗?如果是这样 - 它看起来在语法上不正确。如果不正确 - 您可以更改答案以包含此文件的完整内容吗?
    • Vignesh 你能仔细检查我上面的评论吗^^
    • 当我尝试将完整的文件拼凑在一起时,似乎无法解决任何问题:ReferenceError: helpers is not defined
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-29
    • 1970-01-01
    • 2020-06-17
    • 1970-01-01
    • 2016-07-18
    相关资源
    最近更新 更多