npm start不能运行Angular 2 QuickStart。

8
当我运行 npm start 时,我遇到了以下错误。
C:\angular2-quickstart>npm start

> angular2-quickstart@1.0.0 start C:\angular2-quickstart
> concurrent "npm run tsc:w" "npm run lite"

[0]
[0] > angular2-quickstart@1.0.0 tsc:w C:\angular2-quickstart
[0] > tsc -w
[0]
[1]
[1] > angular2-quickstart@1.0.0 lite C:\angular2-quickstart
[1] > lite-server
[1]
[1] 'lite-server' is not recognized as an internal or external command,
[1] operable program or batch file.
[1]
[1] npm
[1]
[1] ERR!
[1]  angular2-quickstart@1.0.0 lite: `lite-server`
[1] npm
[1]
[1] ERR!
[1]  Exit status 1
[1] npm
[1]
[1] ERR!
[1]
[1] npm
[1] ERR!
[1]  Failed at the angular2-quickstart@1.0.0 lite script.
[1] npm
[1]
[1] ERR!
[1]  This is most likely a problem with the angular2-quickstart package,
[1] npm ERR! not with npm itself.
[1] npm ERR! Tell the author that this fails on your system:
[1] npm
[1]
[1] ERR!
[1]      lite-server
[1] npm
[1]
[1] ERR!
[1]  You can get their info via:
[1] npm
[1]  ERR!     npm owner ls angular2-quickstart
[1] npm
[1] ERR! There is likely additional logging output above.
[1] npm ERR! System Windows_NT 6.1.7601
[1] npm ERR! command "C:\\Software\\npm-1.4.9\\node.exe" "C:\\Software\\npm-1.4.
9\\node_modules\\npm\\bin\\npm-cli.js" "run" "lite"
[1] npm ERR! cwd C:\angular2-quickstart
[1] npm ERR! node -v v5.0.0
[1] npm ERR! npm -v 1.4.9
[1] npm ERR! code ELIFECYCLE
[1] npm ERR!
[1] npm ERR! Additional logging details can be found in:
[1] npm ERR!     C:\angular2-quickstart\npm-debug.log
[1] npm ERR! not ok code 0
[1] npm run lite exited with code 1
[0] node_modules/angular2/src/core/change_detection/parser/locals.d.ts(3,14): er    ror TS2304: Cannot find name 'Map'.
[0] node_modules/angular2/src/core/change_detection/parser/locals.d.ts(4,42): er    ror TS2304: Cannot find name 'Map'.
[0] node_modules/angular2/src/core/debug/debug_node.d.ts(14,13): error TS2304: C
annot find name 'Map'.
[0] node_modules/angular2/src/core/debug/debug_node.d.ts(24,17): error TS2304: C
annot find name 'Map'.
[0] node_modules/angular2/src/core/debug/debug_node.d.ts(25,17): error TS2304: C
annot find name 'Map'.
[0] node_modules/angular2/src/core/di/provider.d.ts(436,103): error TS2304: Cannot find name 'Map'.
[0] node_modules/angular2/src/core/di/provider.d.ts(436,135): error TS2304: Cannot find name 'Map'.
[0] node_modules/angular2/src/core/render/api.d.ts(13,13): error TS2304: Cannot find name 'Map'.
[0] node_modules/angular2/src/core/render/api.d.ts(14,84): error TS2304: Cannot find name 'Map'.
[0] node_modules/angular2/src/facade/collection.d.ts(1,25): error TS2304: Cannot find name 'MapConstructor'.
[0] node_modules/angular2/src/facade/collection.d.ts(2,25): error TS2304: Cannot find name 'SetConstructor'.
[0] node_modules/angular2/src/facade/collection.d.ts(4,27): error TS2304: Cannot find name 'Map'.
[0] node_modules/angular2/src/facade/collection.d.ts(4,39): error TS2304: Cannot find name 'Map'.
[0] node_modules/angular2/src/facade/collection.d.ts(7,9): error TS2304: Cannot find name 'Map'.
[0] node_modules/angular2/src/facade/collection.d.ts(8,30): error TS2304: Cannot find name 'Map'.
[0] node_modules/angular2/src/facade/collection.d.ts(11,43): error TS2304: Cannot find name 'Map'.
[0] node_modules/angular2/src/facade/collection.d.ts(12,27): error TS2304: Cannot find name 'Map'.
[0] node_modules/angular2/src/facade/collection.d.ts(14,23): error TS2304: Cannot find name 'Map'.
[0] node_modules/angular2/src/facade/collection.d.ts(15,25): error TS2304: Cannot find name 'Map'.
[0] node_modules/angular2/src/facade/collection.d.ts(95,41): error TS2304: Cannot find name 'Set'.
[0] node_modules/angular2/src/facade/collection.d.ts(96,22): error TS2304: Canno
t find name 'Set'.
[0] node_modules/angular2/src/facade/collection.d.ts(97,25): error TS2304: Canno
t find name 'Set'.
[0] node_modules/angular2/src/facade/lang.d.ts(13,17): error TS2304: Cannot find
 name 'Map'.
[0] node_modules/angular2/src/facade/lang.d.ts(14,17): error TS2304: Cannot find
 name 'Set'.
[0] node_modules/angular2/src/facade/lang.d.ts(78,59): error TS2304: Cannot find
 name 'Map'.
[0] node_modules/angular2/src/facade/promise.d.ts(1,10): error TS2304: Cannot fi
nd name 'Promise'.
[0] node_modules/angular2/src/facade/promise.d.ts(3,14): error TS2304: Cannot fi
nd name 'Promise'.
[0] node_modules/angular2/src/facade/promise.d.ts(8,32): error TS2304: Cannot fi
nd name 'Promise'.
[0] node_modules/angular2/src/facade/promise.d.ts(9,38): error TS2304: Cannot fi
nd name 'Promise'.
[0] node_modules/angular2/src/facade/promise.d.ts(10,35): error TS2304: Cannot f
ind name 'Promise'.
[0] node_modules/angular2/src/facade/promise.d.ts(10,93): error TS2304: Cannot f
ind name 'Promise'.
[0] node_modules/angular2/src/facade/promise.d.ts(11,34): error TS2304: Cannot f
ind name 'Promise'.
[0] node_modules/angular2/src/facade/promise.d.ts(12,32): error TS2304: Cannot f
ind name 'Promise'.
[0] node_modules/angular2/src/facade/promise.d.ts(12,149): error TS2304: Cannot
find name 'Promise'.
[0] node_modules/angular2/src/facade/promise.d.ts(13,43): error TS2304: Cannot f
ind name 'Promise'.
[0] node_modules/angular2/src/platform/browser/browser_adapter.d.ts(75,33): erro
r TS2304: Cannot find name 'Map'.
[0] node_modules/angular2/src/platform/dom/dom_adapter.d.ts(85,42): error TS2304
: Cannot find name 'Map'.
[0] node_modules/rxjs/CoreOperators.d.ts(22,67): error TS2304: Cannot find name
'Promise'.
[0] node_modules/rxjs/CoreOperators.d.ts(72,67): error TS2304: Cannot find name
'Promise'.
[0] node_modules/rxjs/CoreOperators.d.ts(77,31): error TS2304: Cannot find name
'PromiseConstructor'.
[0] node_modules/rxjs/CoreOperators.d.ts(77,54): error TS2304: Cannot find name
'Promise'.
[0] node_modules/rxjs/Observable.d.ts(65,67): error TS2304: Cannot find name 'Pr
omiseConstructor'.
[0] node_modules/rxjs/Observable.d.ts(65,88): error TS2304: Cannot find name 'Pr
omise'.
[0] node_modules/rxjs/Observable.d.ts(72,84): error TS2304: Cannot find name 'Pr
omise'.
[0] node_modules/rxjs/Observable.d.ts(77,38): error TS2304: Cannot find name 'Pr
omise'.
[0] node_modules/rxjs/Observable.d.ts(100,66): error TS2304: Cannot find name 'P
romise'.
[0] node_modules/rxjs/Observable.d.ts(154,66): error TS2304: Cannot find name 'P
romise'.
[0] node_modules/rxjs/Observable.d.ts(159,31): error TS2304: Cannot find name 'P
romiseConstructor'.
[0] node_modules/rxjs/Observable.d.ts(159,54): error TS2304: Cannot find name 'P
romise'.
[0] 11:22:53 AM - Compilation complete. Watching for file changes.

编辑: 我的package.json文件如下:

{
  "name": "angular2-quickstart",
  "version": "1.0.0",
  "scripts": {
    "postinstall": "npm run typings install",
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "lite": "lite-server",
    "start": "concurrent \"npm run tsc:w\" \"npm run lite\" ",
    "typings" : "typings"
  },
  "license": "ISC",
  "dependencies": {
    "angular2": "2.0.0-beta.6",
    "systemjs": "0.19.20",
    "es6-promise": "^3.0.2",
    "es6-shim": "^0.33.3",
    "reflect-metadata": "0.1.2",
    "rxjs": "5.0.0-beta.0",
    "zone.js": "0.5.14"
  },
  "devDependencies": {
    "concurrently": "^1.0.0",
    "lite-server": "^2.0.1",
    "typescript": "^1.7.5",
    "typings":"^0.6.8"
  }
}

版本如下:
C:\angular2-quickstart>node -v
v5.0.0

C:\angular2-quickstart>npm -v
1.4.9
4个回答

15

尝试执行以下命令:

npm uninstall lite-server

npm install -g concurrently

npm install -g lite-server

npm install -g typescript


14

这个错误是由 TypeScript 定义文件缺失引起的。请确保你的 Angular 版本是正确的。最近一个 beta 版本自动包含这些定义的功能已经被移除了。你可以使用 typingstsd 在本地安装这些定义。

  • Typings: npm install -g typings
  • Tsd: npm install -g tsd

然后运行对应工具的命令来安装报错所需的定义文件。


我已更新问题并附上了我的package.json和npm版本。以下是链接:https://angular.io/docs/ts/latest/quickstart.html - Partha Sarathi Ghosh
将 postinstall 更改为 "postinstall": "typings install" - MTo

1

我遇到了类似的问题,因为我忘记运行:

npm install

在快速入门被克隆之后。通过安装所有依赖项解决了该问题。

1

当我运行npm install时,遇到了同样的问题,在Package.json文件的devdependencies部分添加typeings版本解决了这个问题。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接