角速度快速启动错误

时间:2017-06-12 15:13:06

标签: angularjs node.js

我正在尝试从angular.io运行教程。我在npm start时遇到错误。 这是错误。我试图卸载所有npm,typescript,node,angular。 错误的第一部分:

npm WARN invalid config loglevel="notice"
> angular-quickstart@1.0.0 build C:\Users\Gia\quickstart
> tsc -p src/
    src/app/app.component.spec.ts(3,50): error TS2307: Cannot find module '@angular/core/testing'.
src/app/app.component.spec.ts(4,30): error TS2307: Cannot find module '@angular/platform-browser'.
src/app/app.component.spec.ts(5,30): error TS2307: Cannot find module '@angular/core'.
src/app/app.component.spec.ts(7,1): error TS2304: Cannot find name 'describe'.
src/app/app.component.spec.ts(12,3): error TS2304: Cannot find name 'beforeEach'.
src/app/app.component.spec.ts(19,3): error TS2304: Cannot find name 'beforeEach'.
src/app/app.component.spec.ts(25,3): error TS2304: Cannot find name 'it'.
src/app/app.component.spec.ts(25,39): error TS2304: Cannot find name 'expect'.
src/app/app.component.spec.ts(27,3): error TS2304: Cannot find name 'it'.
src/app/app.component.spec.ts(30,5): error TS2304: Cannot find name 'expect'.
src/app/app.component.ts(1,27): error TS2307: Cannot find module '@angular/core'.
src/app/app.module.ts(1,31): error TS2307: Cannot find module '@angular/core'.
src/app/app.module.ts(2,31): error TS2307: Cannot find module '@angular/platform-browser'.
src/main.ts(1,40): error TS2307: Cannot find module '@angular/platform-browser-dynamic'.

错误的第二部分:

    npm ERR! code ELIFECYCLE
    npm ERR! errno 2
    npm ERR! angular-quickstart@1.0.0 build: `tsc -p src/`
    npm ERR! Exit status 2
    npm ERR!
    npm ERR! Failed at the angular-quickstart@1.0.0 build 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\Gia\AppData\Roaming\npm-cache\_logs\2017-06-12T15_05_48_144Z-debug.log
    npm ERR! code ELIFECYCLE
    npm ERR! errno 2
    npm ERR! angular-quickstart@1.0.0 prestart: `npm run build`
    npm ERR! Exit status 2
    npm ERR!
    npm ERR! Failed at the angular-quickstart@1.0.0 prestart script.
    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

这是package.json文件:

    {
      "name": "angular-quickstart",
      "version": "1.0.0",
      "description": "QuickStart package.json from the documentation, supplemented with testing support",
      "scripts": {
        "build": "tsc -p src/",
        "build:watch": "tsc -p src/ -w",
        "build:e2e": "tsc -p e2e/",
        "serve": "lite-server -c=bs-config.json",
        "serve:e2e": "lite-server -c=bs-config.e2e.json",
        "prestart": "npm run build",
        "start": "concurrently \"npm run tsc:w\" \"npm run serve\"",
        "pree2e": "npm run build:e2e",
        "e2e": "concurrently \"npm run serve:e2e\" \"npm run protractor\" --kill-others --success first",
        "preprotractor": "webdriver-manager update",
        "protractor": "protractor protractor.config.js",
        "pretest": "npm run build",
        "test": "concurrently \"npm run build:watch\" \"karma start karma.conf.js\"",
        "pretest:once": "npm run build",
        "test:once": "karma start karma.conf.js --single-run",
        "lint": "tslint ./src/**/*.ts -t verbose"
      },
      "keywords": [],
      "author": "",
      "license": "MIT",
      "dependencies": {
        "@angular/common": "~4.0.0",
        "@angular/compiler": "~4.0.0",
        "@angular/core": "~4.0.0",
        "@angular/forms": "~4.0.0",
        "@angular/http": "~4.0.0",
        "@angular/platform-browser": "~4.0.0",
        "@angular/platform-browser-dynamic": "~4.0.0",
        "@angular/router": "~4.0.0",
        "angular": "^1.6.4",
        "angular-in-memory-web-api": "~0.3.0",
        "core-js": "^2.4.1",
        "node": "0.0.0",
        "rxjs": "5.0.1",
        "systemjs": "0.19.40",
        "zone.js": "^0.8.4"
      },
      "devDependencies": {
        "concurrently": "^3.2.0",
        "lite-server": "^2.2.2",
        "typescript": "~2.1.0",
        "canonical-path": "0.0.2",
        "tslint": "^3.15.1",
        "lodash": "^4.16.4",
        "jasmine-core": "~2.4.1",
        "karma": "^1.3.0",
        "karma-chrome-launcher": "^2.0.0",
        "karma-cli": "^1.0.1",
        "karma-jasmine": "^1.0.2",
        "karma-jasmine-html-reporter": "^0.2.2",
        "protractor": "~4.0.14",
        "rimraf": "^2.5.4",
        "@types/node": "^6.0.46",
        "@types/jasmine": "2.5.36"
      },
      "repository": {}
    }

在应用程序文件夹中安装npm后出现错误:

src/app/app.component.spec.ts(3,50): error TS2307: Cannot find module '@angular/core/testing'.
src/app/app.component.spec.ts(4,30): error TS2307: Cannot find module '@angular/platform-browser'.
src/app/app.component.spec.ts(5,30): error TS2307: Cannot find module '@angular/core'.
src/app/app.component.ts(1,27): error TS2307: Cannot find module '@angular/core'.
src/app/app.module.ts(1,31): error TS2307: Cannot find module '@angular/core'.
src/app/app.module.ts(2,31): error TS2307: Cannot find module '@angular/platform-browser'.
src/main.ts(1,40): error TS2307: Cannot find module '@angular/platform-browser-dynamic'.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! angular-quickstart@1.0.0 build: `tsc -p src/`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the angular-quickstart@1.0.0 build 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\Gia\AppData\Roaming\npm-cache\_logs\2017-06-12T15_26_01_665Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! angular-quickstart@1.0.0 prestart: `npm run build`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the angular-quickstart@1.0.0 prestart script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

1 个答案:

答案 0 :(得分:0)

这些大多是测试文件中的错误或每个组件中缺少导入。在成功编译应用程序之前,您需要修复所有这些问题。它似乎不是一个错误。

我建议使用angular-cli创建一个新的角度应用程序,并继续从那里构建教程组件。 Angular-cli是创建和搭建角度应用程序的官方工具。