2

我是 Angular 2 的新手。我完成了5 分钟的快速入门教程,然后继续尝试这个ScotchIO 示例。我只是尝试使用与示例中相同的代码。当我npm start通过安装节点模块后运行命令npm install时出现跟随异常。

[system]:~/Coding/Angular2/SecondApp$ npm start

> learning-angular@1.0.0 start /home/swetha/Coding/Angular2/SecondApp
> tsc && concurrently "npm run tsc:w" "npm run lite" 

node_modules/@angular/core/src/application_ref.d.ts(79,88): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/application_ref.d.ts(137,42): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/application_ref.d.ts(196,33): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/change_detection/differs/default_keyvalue_differ.d.ts(24,15): error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/change_detection/differs/default_keyvalue_differ.d.ts(26,16): error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/di/reflective_provider.d.ts(115,123): error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/di/reflective_provider.d.ts(115,165): error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/facade/async.d.ts(34,33): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/facade/async.d.ts(35,45): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/facade/collection.d.ts(1,25): error TS2304: Cannot find name 'MapConstructor'.
node_modules/@angular/core/src/facade/collection.d.ts(2,25): error TS2304: Cannot find name 'SetConstructor'.
node_modules/@angular/core/src/facade/collection.d.ts(4,27): error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/facade/collection.d.ts(4,39): error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/facade/collection.d.ts(7,9): error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/facade/collection.d.ts(8,30): error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/facade/collection.d.ts(11,43): error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/facade/collection.d.ts(12,27): error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/facade/collection.d.ts(14,23): error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/facade/collection.d.ts(15,25): error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/facade/collection.d.ts(100,41): error TS2304: Cannot find name 'Set'.
node_modules/@angular/core/src/facade/collection.d.ts(101,22): error TS2304: Cannot find name 'Set'.
node_modules/@angular/core/src/facade/collection.d.ts(102,25): error TS2304: Cannot find name 'Set'.
node_modules/@angular/core/src/facade/lang.d.ts(11,17): error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/facade/lang.d.ts(12,17): error TS2304: Cannot find name 'Set'.
node_modules/@angular/core/src/facade/lang.d.ts(68,59): error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/facade/promise.d.ts(9,14): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/facade/promise.d.ts(15,32): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/facade/promise.d.ts(16,38): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/facade/promise.d.ts(17,35): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/facade/promise.d.ts(17,93): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/facade/promise.d.ts(18,34): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/facade/promise.d.ts(18,50): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/facade/promise.d.ts(19,32): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/facade/promise.d.ts(19,149): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/facade/promise.d.ts(20,43): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/linker/compiler.d.ts(13,59): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/linker/component_resolver.d.ts(9,58): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/linker/component_resolver.d.ts(13,49): error TS2304: Cannot find name 'Promise'.

这就是我的项目文件夹结构的样子:

[system]-ThinkPad-L420:~/Coding/Angular2/SecondApp$ ls -ltr
total 48
-rw-rw-r--   1 admin admin   204 Jul 26 21:40 typings.json
-rw-rw-r--   1 admin admin   343 Jul 26 21:40 tsconfig.json
-rw-rw-r--   1 admin admin    22 Jul 26 21:40 style.css
-rw-rw-r--   1 admin admin    19 Jul 26 21:40 script.js
-rw-rw-r--   1 admin admin     0 Jul 26 21:40 README.md
-rw-rw-r--   1 admin admin  1076 Jul 26 21:40 package.json
-rw-rw-r--   1 admin admin   843 Jul 26 21:40 index.html
drwxrwxr-x   2 admin admin  4096 Jul 26 21:54 app
drwxr-xr-x 354 root   root   12288 Jul 26 22:53 node_modules
-rw-rw-r--   1 admin admin  1774 Jul 26 23:09 systemjs.config.js
-rw-rw-r--   1 admin admin  2932 Jul 26 23:09 npm-debug.log

在 StackOverFlow 中尝试了一些建议,但没有任何帮助。

4

1 回答 1

1

如您的项目结构中所示,没有typings文件夹,您在第一个5 分钟快速入门示例中错过了它。

npm install 后,typings 文件夹无法显示。如果是这样,请手动安装它们。

npm run typings install

这应该可以解决问题。

于 2016-07-27T03:07:36.700 回答