2017-04-15 14 views
19

Tôi đang cố gắng tạo ứng dụng Angular 2 với AngularFire2ERROR in ./~/firebase/app/shared_promise.js

Tôi đang theo dõi this guide.

Mỗi lần tôi cố gắng nhập AngularFireModule trong mô-đun ứng dụng của tôi và sau đó làm AngularFireModule.initializeApp (config) trong nhập khẩu Tôi nhận được lỗi sau khi tôi cố gắng chạy ng phục vụ:

ERROR in ./~/firebase/app/shared_promise.js 
Module not found: Error: Can't resolve 'promise-polyfill' in 
'C:\Users\username\Desktop\demo-app\node_modules\firebase\app' 
@ ./~/firebase/app/shared_promise.js 22:35-62 
@ ./~/firebase/app/firebase_app.js 
@ ./~/firebase/app.js 
@ ./~/firebase/firebase-browser.js 
@ ./~/angularfire2/angularfire2.js 
@ ./~/angularfire2/index.js 
@ ./src/app/app.module.ts 
@ ./src/main.ts 
@ multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts 
webpack: Failed to compile. 

Và đây là cách package.json của tôi trông giống như:

{ 
    "name": "xxxxx", 
    "version": "0.0.0", 
    "license": "MIT", 
    "scripts": { 
    "ng": "ng", 
    "start": "ng serve", 
    "build": "ng build", 
    "test": "ng test", 
    "lint": "ng lint", 
    "e2e": "ng e2e" 
    }, 
    "private": true, 
    "dependencies": { 
    "@angular/common": "^2.4.0", 
    "@angular/compiler": "^2.4.0", 
    "@angular/core": "^2.4.0", 
    "@angular/forms": "^2.4.0", 
    "@angular/http": "^2.4.0", 
    "@angular/platform-browser": "^2.4.0", 
    "@angular/platform-browser-dynamic": "^2.4.0", 
    "@angular/router": "^3.4.0", 
    "angularfire2": "^2.0.0-beta.8", 
    "core-js": "^2.4.1", 
    "firebase": "^3.7.8", 
    "rxjs": "^5.1.0", 
    "zone.js": "^0.7.6" 
    }, 
    "devDependencies": { 
    "@angular/cli": "1.0.0-rc.0", 
    "@angular/compiler-cli": "^2.4.0", 
    "@types/jasmine": "2.5.38", 
    "@types/node": "~6.0.60", 
    "codelyzer": "~2.0.0", 
    "jasmine-core": "~2.5.2", 
    "jasmine-spec-reporter": "~3.2.0", 
    "karma": "~1.4.1", 
    "karma-chrome-launcher": "~2.0.0", 
    "karma-cli": "~1.0.1", 
    "karma-jasmine": "~1.1.0", 
    "karma-jasmine-html-reporter": "^0.2.2", 
    "karma-coverage-istanbul-reporter": "^0.2.0", 
    "protractor": "~5.1.0", 
    "ts-node": "~2.0.0", 
    "tslint": "~4.4.2", 
    "typescript": "~2.0.0" 
    } 
} 
+0

bạn đã nhập trong 'app.module.ts' tại 'AngularFireModule' và trong NgModule để nhập? –

+0

yes Tôi đang nhập vào app.module.ts – bekamais

+0

Tôi bị kẹt ở ** 4. Thiết lập @ NgModule ** trong hướng dẫn cài đặt cho AngularFire2, tôi đang làm chính xác những gì hướng dẫn nói nhưng không may mắn – bekamais

Trả lời

79
npm install promise-polyfill --save --save-exact 

Nó hoạt động cho tôi.

+0

hoạt động hoàn hảo cho Lỗi: Không thể giải quyết 'lời hứa-polyfill' !!!! thanks – JamesAnd

6
npm install promise-polyfill --save-exact 

tại dấu nhắc lệnh bạn dán lệnh này và chạy nó, tôi đã cùng một vấn đề và "https://github.com/stefanpenner/es6-promise" bài này giúp tôi giải quyết vấn đề.

6

Phụ thuộc 'hứa hẹn đa điểm' bị thiếu trong gói phiên bản firebase npm 3.7.8, bạn có thể cài đặt gói 'fire-polyfill' hoặc hạ cấp gói firebase thành 3,7.7.

4

Nếu bạn muốn lưu phụ thuộc vào package.json, hãy nhớ bao gồm cờ --save cũng như --save-exact.

npm install promise-polyfill --save --save-exact 
+0

Bạn có lỗi đánh máy trong tên gói. –

+0

@Vitali Kniazeu: Cảm ơn! Bây giờ nó đã được sửa. –

0

Sau đây hoàn toàn giải quyết được sự cố của tôi.

npm install promise-polyfill --save --save-exact 
Các vấn đề liên quan