ngc AoT编译器失败并建议获取最新的node.js和npm

时间:2017-10-03 12:48:52

标签: angular

我正在尝试为Angular 2使用ngc AoT编译器。 这一切都是随着亚当·弗里曼(Adam Freeman)的Angular Pro一书而建立起来的。 在他的部署章节中,他将这些行添加到package.json中的devDependencies:

"@angular/compiler-cli": "2.2.0",
"rollup": "0.36.3",
"rollup-plugin-node-resolve": "2.0.0",
"rollup-plugin-commonjs": "5.0.5",
"rollup-plugin-uglify": "1.0.1",
"rollup-plugin-alias": "1.2.0",
"@angular/tsc-wrapped": "0.4.0"

将这些行放入package.json中的脚本:

"ngc": "ngc -p tsconfig-aot.json",
"roll": "rollup -c rollup-config.js",
"startbundle": "concurrently \"npm run lite\" \"npm run json\" "

这是完整的package.json文件。

{
  "dependencies": {
    "@angular/common": "2.2.0",
    "@angular/compiler": "2.2.0",
    "@angular/core": "2.2.0",
    "@angular/platform-browser": "2.2.0",
    "@angular/platform-browser-dynamic": "2.2.0",
    "@angular/forms": "2.2.0",
    "@angular/http": "2.2.0",
    "@angular/upgrade": "2.2.0",
    "@angular/router": "3.2.0",
    "reflect-metadata": "0.1.8",
    "rxjs": "5.0.0-beta.12",
    "zone.js": "0.6.26",
    "core-js": "2.4.1",
    "classlist.js": "1.1.20150312",
    "systemjs": "0.19.40",
    "bootstrap": "4.0.0-alpha.4",
    "font-awesome": "4.7.0",
    "intl": "1.2.5",
    "html5-history-api": "4.2.7"
  },

  "devDependencies": {
    "lite-server": "2.2.2",
    "typescript": "2.0.2",
    "typings": "1.3.2",
    "concurrently": "2.2.0",
    "systemjs-builder": "0.15.32",
    "json-server": "0.8.21",
    "jsonwebtoken": "7.1.9",
    "@angular/compiler-cli": "2.2.0",
    "rollup": "0.36.3",
    "rollup-plugin-node-resolve": "2.0.0",
    "rollup-plugin-commonjs": "5.0.5",
    "rollup-plugin-uglify": "1.0.1",
    "rollup-plugin-alias": "1.2.0",
    "@angular/tsc-wrapped": "0.4.0"
  },

  "scripts": {
    "start": "concurrently \"npm run tscwatch\" \"npm run lite\" \"npm run json\" ",
    "tsc": "tsc",
    "tscwatch": "tsc -w",
    "lite": "lite-server",
    "json": "json-server data.js -p 3500 -m authMiddleware.js",
    "typings": "typings",
    "postinstall": "typings install",
    "ngc": "ngc -p tsconfig-aot.json",
    "roll": "rollup -c rollup-config.js",
    "startbundle": "concurrently \"npm run lite\" \"npm run json\" "
  }
}

这是tsconfig-aot.json:

{
  "compilerOptions": {
    "target": "es5",
    "module": "es2015",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [ "es2015", "dom" ]
  },
  "files": [
    "app/app.module.ts",
    "app/main.ts"
  ],
  "angularCompilerOptions": {
    "angularCompilerOptions": {
      "genDir": "aot",
      "skipMetadataEmit": true
    }
  }
}

有一个npm-shrinkWrap.json文件,但这里包含的时间太长了。

当我运行" npm run ngc"时,我收到此错误:

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'ngc' ]
2 info using npm@3.10.10
3 info using node@v6.11.3
4 verbose run-script [ 'prengc', 'ngc', 'postngc' ]
5 info lifecycle @~prengc: @
6 silly lifecycle @~prengc: no script for prengc, continuing
7 info lifecycle @~ngc: @
8 verbose lifecycle @~ngc: unsafe-perm in lifecycle true
9 verbose lifecycle @~ngc: PATH: C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin;C:\Books\Apress\ProAngular\Chapt10\SportsStore\node_modules\.bin;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Git\cmd;C:\Program Files\nodejs\;C:\Users\smill\AppData\Local\Microsoft\WindowsApps;C:\Users\smill\AppData\Roaming\npm
10 verbose lifecycle @~ngc: CWD: C:\Books\Apress\ProAngular\Chapt10\SportsStore
11 silly lifecycle @~ngc: Args: [ '/d /s /c', 'ngc -p tsconfig-aot.json' ]
12 silly lifecycle @~ngc: Returned: code: 1  signal: null
13 info lifecycle @~ngc: Failed to exec ngc script
14 verbose stack Error: @ ngc: `ngc -p tsconfig-aot.json`
14 verbose stack Exit status 1
14 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\lifecycle.js:255:16)
14 verbose stack     at emitTwo (events.js:106:13)
14 verbose stack     at EventEmitter.emit (events.js:191:7)
14 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\spawn.js:40:14)
14 verbose stack     at emitTwo (events.js:106:13)
14 verbose stack     at ChildProcess.emit (events.js:191:7)
14 verbose stack     at maybeClose (internal/child_process.js:920:16)
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:230:5)
15 verbose pkgid @
16 verbose cwd C:\Books\Apress\ProAngular\Chapt10\SportsStore
17 error Windows_NT 10.0.15063
18 error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "ngc"
19 error node v6.11.3
20 error npm  v3.10.10
21 error code ELIFECYCLE
22 error @ ngc: `ngc -p tsconfig-aot.json`
22 error Exit status 1
23 error Failed at the @ ngc script 'ngc -p tsconfig-aot.json'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the  package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error     ngc -p tsconfig-aot.json
23 error You can get information on how to open an issue for this project with:
23 error     npm bugs
23 error Or if that isn't available, you can get their info via:
23 error     npm owner ls
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]

它说确保我有最新的节点和npm。 几个星期前我安装了节点。 然后我跑了npm install -g npm @ next 将其提升至5.4.2

这引起了各种各样的问题所以我把所有东西都卷回来: 节点v6.11.3 和 上面的节点版本附带的npm 3.10.10。

我在Windows 10上尝试运行Angular 2。

0 个答案:

没有答案