0
votes

I use mac ox (10.11.6), and tried to learn Angular. I installed node.js, typescript and angular-cli, and every thing works well.

However, when I ran "ng serve", they always popped out the error message“webpack: Failed to compile”. Can somebody help me out?

Qiangs-MacBook-Pro:src qiangcao$ ng serve

** NG Live Development Server is running on http://localhost:4200. ** 10% building modules 5/8 modules 3 active ...s/webpack-dev-server/client/socket.js(node:84417) DeprecationWarning: loaderUtils.parseQuery() received a non-string value which can be problematic, see https://github.com/webpack/loader-utils/issues/56 parseQuery() will be replaced with getOptions() in the next major version of loader-utils.

8083ms building modules 4ms add0m155ms2550ms asset80ms

emittinggHash: 3f9353293ca829d9b9e1

Version: webpack 2.1.0-beta.25

Time: 11373ms Asset Size Chunks Chunk Names main.bundle.js 2.74 MB 0, 2 [emitted] main

styles.bundle.js 9.98 kB 1, 2 [emitted] styles inline.js 5.53 kB 2 [emitted] inline main.map 2.79 MB 0, 2 [emitted] main styles.map 13.4 kB 1, 2 [emitted] styles inline.map 5.55 kB 2 [emitted] inline index.html 485 bytes [emitted]

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:126:37 A parameter initializer is only allowed in a function or constructor implementation.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:126:45 Cannot find name 'keyof'.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:126:51 '=' expected.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:134:45 A parameter initializer is only allowed in a function or constructor implementation.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:134:55 Cannot find name 'keyof'.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:134:61 '=' expected.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:142:29 ',' expected.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:142:46 ';' expected.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:142:67 Cannot find name 'ReadonlyArray'.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:142:89 '(' expected.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:142:91 The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:142:93 Cannot find name 'methodName'.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:142:103 ']' expected.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:142:105 Cannot find name 'string'.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:142:111 ',' expected.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:142:112 Property assignment expected.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:142:120 ')' expected.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:142:123 Cannot find name 'ReadonlyArray'.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:142:137 Cannot find name 'keyof'.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:142:143 ')' expected.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:142:143 Cannot find name 'T'.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:142:143 The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:142:146 Expression expected.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:142:148 The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:142:149 A computed property name must be of type 'string', 'number', 'symbol', or 'any'.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:142:150 Cannot find name 'P'.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:142:155 Cannot find name 'keyof'.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:142:161 ']' expected.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:142:161 Cannot find name 'T'.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:142:162 ',' expected.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:142:163 Property assignment expected.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:142:164 Property assignment expected.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:142:178 ',' expected.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:142:179 Cannot find name 'P'.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:142:182 ':' expected.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:142:207 '{' expected.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:142:216 ':' expected.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:142:216 Cannot find name 'T'.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:142:218 Cannot find name 'P'.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:142:221 ',' expected.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:142:223 An object literal cannot have multiple properties with the same name in strict mode.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:142:226 ':' expected.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:142:227 Expression expected.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:142:228 ';' expected.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:154:41 Cannot find name 'Partial'.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:157:57 Generic type 'SpyObjMethodNames' requires 2 type argument(s).

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:158:60 Generic type 'SpyObjMethodNames' requires 2 type argument(s).

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:160:39 Generic type 'SpyObjMethodNames' requires 2 type argument(s).

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:161:42 Generic type 'SpyObjMethodNames' requires 2 type argument(s).

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:198:21 Cannot find name 'Partial'.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:198:34 Cannot find name 'Partial'.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:575:12 Invalid use of 'arguments'. Modules are automatically in strict mode.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:635:8 A computed property name must be of type 'string', 'number', 'symbol', or 'any'.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:635:9 Cannot find name 'k'.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:635:14 Cannot find name 'keyof'.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:635:20 ']' expected.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:635:20 Cannot find name 'T'.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:635:21 ';' expected.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:635:22 Declaration or statement expected.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:635:24 Cannot find name 'T'.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:635:26 Cannot find name 'k'.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:635:29 ';' expected.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:635:48 Cannot find name 'T'.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:635:50 Cannot find name 'k'.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:635:55 Cannot find name 'Spy'.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:635:61 Cannot find name 'T'.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:635:63 Cannot find name 'k'.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:642:23 Cannot find name 'Spy'.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:644:31 Cannot find name 'Spy'.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:646:40 Cannot find name 'Spy'.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:648:32 Cannot find name 'Spy'.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:650:33 Cannot find name 'Spy'.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:652:16 Cannot find name 'Spy'.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:691:36 Cannot find name 'Reporter'.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:697:20 Cannot find name 'RunDetails'.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:701:18 Cannot find name 'Suite'.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:702:32 Cannot find name 'SuiteOrSpec'.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:711:14 Cannot find name 'Spec'.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:712:15 Cannot find name 'Clock'.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:716:29 Cannot find name 'HtmlReporter'.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:717:31 Cannot find name 'HtmlSpecFilter'.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:720:0 Declaration or statement expected.

ERROR in [default] /Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index.d.ts:725:25 Module '"/Users/qiangcao/angular2_hello_world/node_modules/@types/jasmine/index".jasmine' has no exported member 'Jasmine'. Child html-webpack-plugin for "index.html": Asset Size Chunks Chunk Names index.html 2.94 kB 0 webpack: Failed to compile.

1
you ran ng server or ng serve?Akber Iqbal
@AkberIqbal I ran ng serveJohn
i would do npm uninstall @types/jasmine and then npm i @types/jasmine... else, kindly update the question with output of ng -vAkber Iqbal
@AkberIqbal I did these two commands, however, still have error. And the output of "ng -v": angular-cli: 1.0.0-beta.18 node: 10.15.3 os: darwin x64John
you have a deprecated version of angular (ref:npmjs.com/package/angular-cli/v/1.0.0-beta.18)... npm uninstall @angular/cli then npm install @angular/cli@latestAkber Iqbal

1 Answers

1
votes

from the comments above:

  • You have a deprecated version of angular (ref:npmjs.com/package/angular-cli/v/1.0.0-beta.18)... npm uninstall @angular/cli then npm install @angular/cli@latest

on your comment about getting the old angular/cli version to work:

  • The old version might not work with newer npm and node... if you really want to get the old version working, i'd suggest go to a test machine and install relevant npm and node and angular/cli versions of the same time period as angular-cli version 1.0.0-beta.18