错误在./~/firebase/app/shared_promise.js

时间:2022-05-13 20:01:45

I'm trying to create an Angular 2 App with AngularFire2

我正在尝试使用AngularFire2创建一个Angular 2应用程序

I was following this guide.

我正在遵循这个指南。

Everytime I try to import the AngularFireModule in my app module and then do AngularFireModule.initializeApp(config) in the imports I'm getting the following error when I try to run ng serve:

每次我尝试在我的应用程序模块中导入AngularFireModule然后在导入中执行AngularFireModule.initializeApp(config)我在尝试运行ng服务时遇到以下错误:

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.

And this is how my package.json look like:

这就是我的package.json的样子:

 {
     "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"
  }
}

5 个解决方案

#1


80  

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

It works for me.

这个对我有用。

#2


6  

npm install promise-polyfill --save-exact

in your command prompt paste this command and run it, I had the same problem and "https://github.com/stefanpenner/es6-promise" this post helped me to resolve the problem.

在你的命令提示符粘贴此命令并运行它,我有同样的问题和“https://github.com/stefanpenner/es6-promise”这篇文章帮助我解决了这个问题。

#3


6  

The 'promise-polyfill' dependencie is missing in firebase npm package version 3.7.8, you can install 'promise-polyfill' or downgrade firebase package to 3.7.7.

firebase npm软件包版本3.7.8中缺少'promise-polyfill'依赖项,您可以安装'promise-polyfill'或将firebase软件包降级到3.7.7。

#4


4  

If you'd like to have the dependency saved as well in package.json, be sure to include the --save flag as well as the --save-exact.

如果你想在package.json中保存依赖项,请确保包含--save标志以及--save-exact。

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

#5


1  

The following completely solves my problem.

以下完全解决了我的问题。

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

#1


80  

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

It works for me.

这个对我有用。

#2


6  

npm install promise-polyfill --save-exact

in your command prompt paste this command and run it, I had the same problem and "https://github.com/stefanpenner/es6-promise" this post helped me to resolve the problem.

在你的命令提示符粘贴此命令并运行它,我有同样的问题和“https://github.com/stefanpenner/es6-promise”这篇文章帮助我解决了这个问题。

#3


6  

The 'promise-polyfill' dependencie is missing in firebase npm package version 3.7.8, you can install 'promise-polyfill' or downgrade firebase package to 3.7.7.

firebase npm软件包版本3.7.8中缺少'promise-polyfill'依赖项,您可以安装'promise-polyfill'或将firebase软件包降级到3.7.7。

#4


4  

If you'd like to have the dependency saved as well in package.json, be sure to include the --save flag as well as the --save-exact.

如果你想在package.json中保存依赖项,请确保包含--save标志以及--save-exact。

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

#5


1  

The following completely solves my problem.

以下完全解决了我的问题。

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