0

私はAngular 2が初めてです。

私は Angular.io のヒーロー アプリのツアーに取り組んでいます。私はAngular 2を手に入れるためにそれを修正しています。

クリックするとポップアップが表示されるボタンを作成しました。現在、ポップアップを実装していますが、この依存関係に遭遇しました。" --ng2-opd-popup."

ポップアップを使用できるようにプロジェクトに追加していましたが、ここで事態が悪化しました。

依存関係を追加するには、次の手順を実行しました。

  1. package.json にエントリを作成しました "ng2-opd-popup": "^1.1.21",
  2. コマンドを実行 - npm install ng2-opd-popup --save 。
  3. 「ng2-opd-popup」から app.module.ts .import { PopupModule } にインポートしました。
  4. サーバーを実行しました:

しかし、それはエラーを出しました:

ここに画像の説明を入力

私のパッケージJSON

{
  "name": "angular-io-example",
  "version": "1.0.0",
  "private": true,
  "description": "Example project from an angular.io guide.",
  "scripts": {
    "test:once": "karma start karma.conf.js --single-run",
    "build": "tsc -p src/",
    "serve": "lite-server -c=bs-config.json",
    "prestart": "npm run build",
    "start": "concurrently \"npm run build:watch\" \"npm run serve\"",
    "pretest": "npm run build",
    "test": "concurrently \"npm run build:watch\" \"karma start karma.conf.js\"",
    "pretest:once": "npm run build",
    "build:watch": "tsc -p src/ -w",
    "build:upgrade": "tsc",
    "serve:upgrade": "http-server",
    "build:aot": "ngc -p tsconfig-aot.json && rollup -c rollup-config.js",
    "serve:aot": "lite-server -c bs-config.aot.json",
    "build:babel": "babel src -d src --extensions \".es6\" --source-maps",
    "copy-dist-files": "node ./copy-dist-files.js",
    "i18n": "ng-xi18n",
    "lint": "tslint ./src/**/*.ts -t verbose"
  },
  "keywords": [],
  "author": "",
  "license": "MIT",
  "dependencies": {
    "@angular/animations": "~4.3.1",
    "@angular/common": "~4.3.1",
    "@angular/compiler": "~4.3.1",
    "@angular/compiler-cli": "~4.3.1",
    "@angular/core": "~4.3.1",
    "@angular/forms": "~4.3.1",
    "@angular/http": "~4.3.1",
    "@angular/platform-browser": "~4.3.1",
    "@angular/platform-browser-dynamic": "~4.3.1",
    "@angular/platform-server": "~4.3.1",
    "@angular/router": "~4.3.1",
    "@angular/tsc-wrapped": "~4.3.1",
    "@angular/upgrade": "~4.3.1",
    "angular-in-memory-web-api": "~0.3.2",
    "core-js": "^2.4.1",
    "ng2-opd-popup": "^1.1.21",
    "rxjs": "^5.1.0",
    "systemjs": "0.19.39",
    "zone.js": "^0.8.4"
  },
  "devDependencies": {
    "@types/angular": "^1.5.16",
    "@types/angular-animate": "^1.5.5",
    "@types/angular-cookies": "^1.4.2",
    "@types/angular-mocks": "^1.5.5",
    "@types/angular-resource": "^1.5.6",
    "@types/angular-route": "^1.3.2",
    "@types/angular-sanitize": "^1.3.3",
    "@types/jasmine": "2.5.36",
    "@types/node": "^6.0.45",
    "babel-cli": "^6.16.0",
    "babel-preset-angular2": "^0.0.2",
    "babel-preset-es2015": "^6.16.0",
    "canonical-path": "0.0.2",
    "concurrently": "^3.0.0",
    "http-server": "^0.9.0",
    "jasmine": "~2.4.1",
    "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",
    "karma-phantomjs-launcher": "^1.0.2",
    "lite-server": "^2.2.2",
    "lodash": "^4.16.2",
    "phantomjs-prebuilt": "^2.1.7",
    "protractor": "~5.1.0",
    "rollup": "^0.41.6",
    "rollup-plugin-commonjs": "^8.0.2",
    "rollup-plugin-node-resolve": "2.0.0",
    "rollup-plugin-uglify": "^1.0.1",
    "source-map-explorer": "^1.3.2",
    "tslint": "^3.15.1",
    "typescript": "~2.3.2"
  },
  "repository": {}
}

以下は私のapp.module.tsです:-

import { NgModule }      from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule }   from '@angular/forms';
import { HttpModule }    from '@angular/http';

import { AppRoutingModule } from './app-routing.module';

// Imports for loading & configuring the in-memory web api
import { InMemoryWebApiModule } from 'angular-in-memory-web-api';
import { InMemoryDataService }  from './in-memory-data.service';

import { AppComponent }         from './app.component';
import { DashboardComponent }   from './dashboard.component';
import { HeroesComponent }      from './heroes.component';
import { HeroDetailComponent }  from './hero-detail.component';
import { HeroService }          from './hero.service';
import { ProfileService }       from './profile.service';
import { HeroSearchComponent }  from './hero-search.component';
import { PopupModule }          from 'ng2-opd-popup';


@NgModule({
  imports: [
    BrowserModule,
    FormsModule,
    PopupModule.forRoot(),
    HttpModule,
    //InMemoryWebApiModule.forRoot(InMemoryDataService),
    AppRoutingModule
  ],
  declarations: [
    AppComponent,
    DashboardComponent,
    HeroDetailComponent,
    HeroesComponent,
    HeroSearchComponent
  ],
  providers: [ HeroService ,ProfileService],
  bootstrap: [ AppComponent ]
})
export class AppModule { }

私のsystem.config.js

/**
 * System configuration for Angular samples
 * Adjust as necessary for your application needs.
 */
(function (global) {
  System.config({
    paths: {
      // paths serve as alias
      'npm:': 'node_modules/'
    },
    // map tells the System loader where to look for things
    map: {
      // our app is within the app folder
      'app': 'app',

      // angular bundles
      '@angular/animations': 'npm:@angular/animations/bundles/animations.umd.js',
      '@angular/animations/browser': 'npm:@angular/animations/bundles/animations-browser.umd.js',
      '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
      '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
      '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
      '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
      '@angular/platform-browser/animations': 'npm:@angular/platform-browser/bundles/platform-browser-animations.umd.js',
      '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
      '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
      '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
      '@angular/router/upgrade': 'npm:@angular/router/bundles/router-upgrade.umd.js',
      '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
      '@angular/upgrade': 'npm:@angular/upgrade/bundles/upgrade.umd.js',
      '@angular/upgrade/static': 'npm:@angular/upgrade/bundles/upgrade-static.umd.js',

      // other libraries
      'rxjs':                      'npm:rxjs',
      'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
      'ng2-opd-popup' : 'npm:ng2-opd-popup'
    },
    // packages tells the System loader how to load when no filename and/or no extension
    packages: {
      app: {
        main: './main.js',
        defaultExtension: 'js',
        meta: {
          './*.js': {
            loader: 'systemjs-angular-loader.js'
          }
        }
      },
      rxjs: {
        defaultExtension: 'js'
      }
    }
  });
})(this);

アプリがプロジェクトで使用できるように、依存関係 ng2-opd-popup を追加するにはどうすればよいですか? 私は何時間もグーグルで過ごしてきましたが、今はどうすればよいかわかりません。

npm install ng2-opd-popup の出力

H:\Heros>npm install ng2-opd-popup --save
angular-io-example@1.0.0 H:\Heros
`-- ng2-opd-popup@1.1.21
  +-- UNMET PEER DEPENDENCY @angular/common@2.3.0
  +-- UNMET PEER DEPENDENCY @angular/compiler@2.2.4
  +-- @angular/compiler-cli@2.3.0
  | `-- @angular/tsc-wrapped@0.4.2
  |   `-- tsickle@0.2.6
  +-- UNMET PEER DEPENDENCY @angular/core@2.3.0
  +-- @angular/forms@2.3.0
  +-- @angular/http@2.3.0
  +-- UNMET PEER DEPENDENCY @angular/platform-browser@2.3.0
  +-- @angular/platform-browser-dynamic@2.3.0
  +-- @angular/router@3.2.4
  +-- UNMET PEER DEPENDENCY rxjs@5.0.0-rc.4
  `-- zone.js@0.7.8

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","ar
ch":"x64"})
npm WARN enoent ENOENT: no such file or directory, open 'H:\Heros\node_modules\angular2-modal\package.json'
npm WARN @angular/platform-browser-dynamic@2.3.0 requires a peer of @angular/compiler@2.3.0 but none was installed.
npm WARN @angular/compiler-cli@2.3.0 requires a peer of @angular/compiler@2.3.0 but none was installed.
npm WARN @angular/router@3.2.4 requires a peer of @angular/core@2.2.4 but none was installed.
npm WARN @angular/router@3.2.4 requires a peer of @angular/common@2.2.4 but none was installed.
npm WARN @angular/router@3.2.4 requires a peer of @angular/platform-browser@2.2.4 but none was installed.
npm WARN @angular/router@3.2.4 requires a peer of rxjs@5.0.0-beta.12 but none was installed.
npm WARN @angular/compiler@2.2.4 requires a peer of @angular/core@2.2.4 but none was installed.
4

0 に答える 0