Angular 2问题:在Git Bash中输入“npm start”时出错

时间:2018-01-31 15:59:35

标签: angular npm

我是Angular 2的初学者。我正在阅读一个名为“通过构建12个应用程序来学习Angular 2”的Udemy课程。我正面临着设置Angular 2的问题。我已完成了名为“Angular 2 Quickstart Setup Interpre”的视频中所示的所有内容。但是当我在Git Bash中输入“npm start”时,我收到了这个错误:

> a2website@1.0.0 start C:\Users\Kanon\Desktop\exercise fies\learn angular by building apps\a2website
> tsc && concurrently "npm run tsc:w" "npm run lite"

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 t      o 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'.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! a2website@1.0.0 start: `tsc && concurrently "npm run tsc:w" "npm run lite" `
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the a2website@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Kanon\AppData\Roaming\npm-cache\_logs\2018-01-31T14_25_27_937Z-debug.log

以下是错误日志文件:

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   'start' ]
2 info using npm@5.6.0
3 info using node@v8.9.4
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle a2website@1.0.0~prestart: a2website@1.0.0
6 info lifecycle a2website@1.0.0~start: a2website@1.0.0
7 verbose lifecycle a2website@1.0.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle a2website@1.0.0~start: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\Kanon\Desktop\exercise fies\learn angular by building apps\a2website\node_modules\.bin;C:\Users\Kanon\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\local\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Users\Kanon\bin;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Brackets\command;C:\Program Files (x86)\Skype\Phone;C:\Program Files\MySQL\MySQL Utilities 1.6;C:\Program Files\nodejs;C:\ProgramData\chocolatey\bin;C:\Users\Kanon\AppData\Local\Programs\Python\Python36-32\Scripts;C:\Users\Kanon\AppData\Local\Programs\Python\Python36-32;C:\Users\Kanon\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Microsoft VS Code\bin;C:\Program Files\Java\jdk1.8.0_144\bin;C:\Users\Kanon\AppData\Roaming\npm;C:\Program Files\erl9.2\bin;C:\Program Files\GTK2-bundle\bin;C:\Program Files\gettext-iconv\bin;C:\Program Files\Git\usr\bin\vendor_perl;C:\Program Files\Git\usr\bin\core_perl
9 verbose lifecycle a2website@1.0.0~start: CWD: C:\Users\Kanon\Desktop\exercise fies\learn angular by building apps\a2website
10 silly lifecycle a2website@1.0.0~start: Args: [ '/d /s /c',
10 silly lifecycle   'tsc && concurrently "npm run tsc:w" "npm run lite" ' ]
11 silly lifecycle a2website@1.0.0~start: Returned: code: 2  signal: null
12 info lifecycle a2website@1.0.0~start: Failed to exec start script
13 verbose stack Error: a2website@1.0.0 start: `tsc && concurrently "npm run tsc:w" "npm run lite" `
13 verbose stack Exit status 2
13 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:285:16)
13 verbose stack     at emitTwo (events.js:126:13)
13 verbose stack     at EventEmitter.emit (events.js:214:7)
13 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at emitTwo (events.js:126:13)
13 verbose stack     at ChildProcess.emit (events.js:214:7)
13 verbose stack     at maybeClose (internal/child_process.js:925:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid a2website@1.0.0
15 verbose cwd C:\Users\Kanon\Desktop\exercise fies\learn angular by building apps\a2website
16 verbose Windows_NT 10.0.15063
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
18 verbose node v8.9.4
19 verbose npm  v5.6.0
20 error code ELIFECYCLE
21 error errno 2
22 error a2website@1.0.0 start: `tsc && concurrently "npm run tsc:w" "npm run lite" `
22 error Exit status 2
23 error Failed at the a2website@1.0.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 2, true ]

您可以在此处找到我的项目文件: https://drive.google.com/open?id=1BlxYt29j7QkGrAdR7Jovid34f5kwXaeE

请帮我找到解决方案。在问题解决之前,我无法继续深入学习。

1 个答案:

答案 0 :(得分:1)

只需升级你的Angular(已经是5.2)。 运行:colour_map = { '20': 'red', '21': 'blue', '22': 'yellow', } color= ['green' if H not in colour_map.keys() else colour_map[H] for H in House] 。 然后,导航到目录并运行yarn add @angular/cli

就是这样, Angular已配置。

另外, 我建议您浏览Angular.io文档并开始使用。它很好,内容丰富。