2017-03-28 4 views
16

이 링크에서 볼 수있는 Angular 2 Routing and Navigation 예제를 따라 왔습니다 : https://plnkr.co/edit/I4ArEQTniO7MJtfzpBWl?p=info.Augular 2 라우터 애니메이션 - '@ angle/platform-browser/animations'모듈을 찾을 수 없습니다.

나는 transpiler를 실행할 때 "client/app/app.module.ts (5,41) : error TS2307 : '@ angular/platform-browser/animations'모듈을 찾을 수 없습니다."라는 오류 메시지가 나타납니다.

내 systemjs.config.js (아래 참조)를 기반으로 '@ angular/platform-browser/animations'모듈이 'platform-browser-animations.umd.js'파일에 있어야합니다. node_modules/@ angular/platform-browser/bundles하지만 거기에는 없습니다. 그때 종속 버전을 설치하려고하지만, 충족되지 않은 의존성 메시지가 계속

+-- UNMET PEER DEPENDENCY @angular/[email protected] 
+-- UNMET PEER DEPENDENCY @angular/[email protected] 
`-- UNMET PEER DEPENDENCY @angular/[email protected] 

다음 누락 된 프레임 워크를 설치하지만, 충족되지 의존성 오류 메시지가 나타날 내가 설치하려고 NPM을 사용하여

//systemjs.config.js 
(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/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' 
}, 
// packages tells the System loader how to load when no filename and/or no extension 
packages: { 
    //app: { 
    // main: './main.js', 
    // defaultExtension: 'js' 
    //}, 
    client: { 
    main: './main.js', 
    defaultExtension: 'js' 
    }, 
    rxjs: { 
    defaultExtension: 'js' 
    } 
} 
}); 
})(this); 

.

>npm install @angular/[email protected] @angular/[email protected] @angular/[email protected] --save 

은 내가 애니메이션 설치된 4.0을 가지고 있고 그것은 내가 설치하지 않을 코어 4.0을 필요로처럼 4.

npm WARN @angular/[email protected] requires a peer of @angular/[email protected] but no 
ne was installed. 

각도 것 같습니다 설치해야 함을 나타냅니다 하나의 경고가 나타났습니다. 애니메이션 4.0을 제거하고 이전 버전의 애니메이션을 설치해야합니까? 내 package.json 파일은 아래와 같습니다.

//package.json 
{ 
"name": "angular-quickstart", 
"version": "1.0.0", 
"description": "QuickStart package.json from the documentation, supplemented with testing support", 
"scripts": { 
"build": "tsc -p client/", 
"build:watch": "tsc -p client/ -w", 
"build:e2e": "tsc -p e2e/", 
"serve:e2e": "lite-server -c=bs-config.e2e.json", 
"prestart": "npm run build", 
"start": "npm run build:watch", 
"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 ./client/**/*.ts -t verbose" 
    }, 
"keywords": [], 
"author": "", 
"license": "MIT", 
"dependencies": { 
"@angular/animations": "^4.0.0", 
"@angular/common": "^2.4.8", 
"@angular/compiler": "~2.4.0", 
"@angular/core": "^2.4.8", 
"@angular/forms": "~2.4.0", 
"@angular/http": "~2.4.0", 
"@angular/platform-browser": "^2.4.10", 
"@angular/platform-browser-dynamic": "~2.4.0", 
"@angular/router": "~3.4.0", 
"angular-animate": "^1.6.3", 
"angular-in-memory-web-api": "~0.2.4", 
"body-parser": "^1.17.0", 
"bootstrap": "^3.3.7", 
"cookie-parser": "^1.4.3", 
"core-js": "^2.4.1", 
"ejs": "^2.5.6", 
"express": "^4.15.0", 
"express-session": "^1.15.1", 
"jade": "^1.11.0", 
"jquery": "^3.1.1", 
"mongoose": "^4.8.5", 
"morgan": "^1.8.1", 
"passport": "^0.3.2", 
"passport-local": "^1.0.0", 
"rxjs": "5.0.1", 
"stylus": "^0.54.5", 
"systemjs": "0.19.40", 
"toastr": "^2.1.2", 
"zone.js": "^0.7.4" 
}, 
"devDependencies": { 
"concurrently": "^3.2.0", 
"lite-server": "^2.2.2", 
"typescript": "~2.0.10", 
"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": {} 
} 

내 애니메이션 버전과 관련된 문제 인 것 같습니다. 동의하면 기존 버전을 제거하는 방법과 내가 설치 한 @ angular/core 버전과 호환되는 버전을 설치해야합니다. 2.4.8. 이것이 문제가 아닌 경우, @ angle/platform-browser/bundle/platform-browser-animations.umd.js 파일을 어떻게 설치합니까?

답변

28

몇 시간 동안 조사한 끝에 2.4.0-2.4.8의 @ angular/core 버전과 호환되는 @ angular/animations 버전을 찾을 수 없었습니다. 나는이 게시물에 대한 대답, How to get list of versions for compatible Angular 2 modules?을 읽었다. 이 게시물은 라우터를 제외한 각도 2의 모든 모듈이 같은 버전이므로 앵귤러/애니메이션 2.4.8을 내 package.json에 연결하고 모든 버전을 애니메이션 항목을 포함하여 2.4.8로 변경했음을 확신했습니다. 나는 뭔가를 놓치지 않았다. 그런 다음 npm을 실행했고 이것은 애니메이션 버전에서 실패했습니다.

마침내이 게시물을 발견했습니다. http://angularjs.blogspot.com/을 각도 4.0으로 업데이트합니다. 게시물에는 누락 된 애니메이션 모듈에 대한 구체적인 언급이 있지만 업그레이드를 통해서만 사용할 수 있습니다. Windows 용 간단한 업데이트 지침을 따랐고 응용 프로그램이 잘 돌아갑니다. 내 응용 프로그램은 가이드의 엄청난 예제와 매우 비슷합니다. 게시물 당 Angular 2.x.x를 실행하는 경우 대부분의 응용 프로그램에서 이전 버전과 호환되어야합니다. 다음은 업그레이드 지침입니다. 4.0.0

업데이트 4로 업데이트

최신 버전, 당신은 애니메이션을 원하는 경우 이중 검사에 각도 의존성을 업데이트하는 것만 큼 쉽습니다. 대부분의 유스 케이스에서 작동합니다.리눅스/맥에

:

NPM은 각도/{일반, 컴파일러, 컴파일러 CLI 코어, 형태, HTTP, 플랫폼 브라우저, 플랫폼 브라우저 동적 플랫폼 서버, 라우터, 애니메이션 @ 설치 } @latest 타이프 @ 최신 --save Windows에서

:

NPM은 각도/각도/컴파일러 @ 일반적인 @ 최신 각도/@ 최신 @ 컴파일러 CLI @ 각도/핵심 @ 최신 @ 최신 @angular @ 설치/최신 @ 각도/http @ 최신 @ 각도/플랫폼 - 브라우저 @ 최신 @ 각도/플랫폼 - 브라우저 - 동적 @ 최신 @ 각도/플랫폼 - 서버 @ 최신 @ 각도/라우터 @ 최신 @ 각도/애니메이션 @ 최신 t ypescript @ 최신 --save

+2

환상적인, 후속 @ j를-테라노바 근무 설치 NPM! – Geoffrey

+1

위대한 답변 - 완벽하게 작동하고이 문제에 대해 엄청난 시간을 낭비하지 않게했습니다. – Shane

+1

이것은 오랫동안 나를 괴롭혔다. 이 솔루션은 완벽합니다! –

2

아래 시도

스텝 1

$ RF RM은 node_modules

$의 NPM 캐시 명확

단계 -2

단계

$는/애니메이션 각도 @ 설치 NPM @ 최신 --save

$가

그것의 나를 위해

+0

'npm'의 최신 버전에서'npm cache clear' 명령은 더 이상 사용 가능하지 않습니다. 캐시를 깨끗하게해야한다면'npm cache verify' 또는'npm cache clear --force' 명령을 사용하십시오. –