将 @angular/fire 添加到 angular 12
Adding @angular/fire to angular 12
我正在尝试将 @angular/fire 添加到我的 Angular 12 项目中,以便我可以将它部署到 Firebase 上。
我使用 cli 添加 @angular/fire
我运行:
ng add @angular/fire
这是我得到的输出:
ℹ Using package manager: npm
✔ Found compatible package version: @angular/fire@0.0.0.
✔ Package information loaded.
The package @angular/fire@0.0.0 will be installed and executed.
Would you like to proceed? Yes
✔ Package successfully installed.
The package that you are trying to add does not support schematics. You can try using a different version of the package or contact the package author to add ng-add support.
我尝试使用 npm 安装依赖项:
npm i @angular/fire
这是输出:
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@angular/animations@12.0.0',
npm WARN EBADENGINE required: { node: '^12.14.1 || ^14.0.0' },
npm WARN EBADENGINE current: { node: 'v16.1.0', npm: '7.13.0' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@angular/common@12.0.0',
npm WARN EBADENGINE required: { node: '^12.14.1 || ^14.0.0' },
npm WARN EBADENGINE current: { node: 'v16.1.0', npm: '7.13.0' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@angular/compiler@12.0.0',
npm WARN EBADENGINE required: { node: '^12.14.1 || ^14.0.0' },
npm WARN EBADENGINE current: { node: 'v16.1.0', npm: '7.13.0' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@angular/compiler-cli@12.0.0',
npm WARN EBADENGINE required: { node: '^12.14.1 || ^14.0.0' },
npm WARN EBADENGINE current: { node: 'v16.1.0', npm: '7.13.0' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@angular/core@12.0.0',
npm WARN EBADENGINE required: { node: '^12.14.1 || ^14.0.0' },
npm WARN EBADENGINE current: { node: 'v16.1.0', npm: '7.13.0' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@angular/forms@12.0.0',
npm WARN EBADENGINE required: { node: '^12.14.1 || ^14.0.0' },
npm WARN EBADENGINE current: { node: 'v16.1.0', npm: '7.13.0' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@angular/platform-browser@12.0.0',
npm WARN EBADENGINE required: { node: '^12.14.1 || ^14.0.0' },
npm WARN EBADENGINE current: { node: 'v16.1.0', npm: '7.13.0' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@angular/platform-browser-dynamic@12.0.0',
npm WARN EBADENGINE required: { node: '^12.14.1 || ^14.0.0' },
npm WARN EBADENGINE current: { node: 'v16.1.0', npm: '7.13.0' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@angular/router@12.0.0',
npm WARN EBADENGINE required: { node: '^12.14.1 || ^14.0.0' },
npm WARN EBADENGINE current: { node: 'v16.1.0', npm: '7.13.0' }
npm WARN EBADENGINE }
up to date, audited 1388 packages in 6s
3 moderate severity vulnerabilities
To address all issues (including breaking changes), run:
npm audit fix --force
Run `npm audit` for details.
这是我的 package.json:
{
"name": "ng-jumbo-fire",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "~12.0.0",
"@angular/cdk": "^11.2.12",
"@angular/common": "~12.0.0",
"@angular/compiler": "~12.0.0",
"@angular/core": "~12.0.0",
"@angular/fire": "^0.0.0",
"@angular/forms": "~12.0.0",
"@angular/material": "^11.2.12",
"@angular/platform-browser": "~12.0.0",
"@angular/platform-browser-dynamic": "~12.0.0",
"@angular/router": "~12.0.0",
"rxjs": "~6.6.0",
"tslib": "^2.0.0",
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.1102.13",
"@angular/compiler-cli": "~12.0.0",
"@types/jasmine": "~3.6.0",
"@types/node": "^12.11.1",
"codelyzer": "^6.0.0",
"jasmine-core": "~3.6.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~6.3.2",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.0.3",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"protractor": "~7.0.0",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"typescript": "~4.2.4"
}
}
如何安装它。我注意到 @angular/fire 的版本是 0.0.0。文件夹 .node_modules/@angular/fire 是空的。
我将不胜感激任何帮助。
如果您查看兼容性矩阵,Angular 12 还不完全支持它。因此,您最好改用 Angular 11。
对于 Angular 12 以下与此类版本的依赖关系解决了我的问题。
安装firebase版本7.0 || 8.0 和 @angular/fire 版本 6.1.5.
package.json 文件夹依赖项应如下所示:
"dependencies": {
...
"@angular/fire": "^6.1.5",
"firebase": "^7.0 || ^8.0"
}
app.module.ts
import { AngularFireModule } from '@angular/fire';
import { AngularFirestoreModule } from '@angular/fire/firestore';
imports: [
...
AngularFireModule.initializeApp(firebaseConfig),
AngularFirestoreModule
],
我正在尝试将 @angular/fire 添加到我的 Angular 12 项目中,以便我可以将它部署到 Firebase 上。 我使用 cli 添加 @angular/fire 我运行:
ng add @angular/fire
这是我得到的输出:
ℹ Using package manager: npm
✔ Found compatible package version: @angular/fire@0.0.0.
✔ Package information loaded.
The package @angular/fire@0.0.0 will be installed and executed.
Would you like to proceed? Yes
✔ Package successfully installed.
The package that you are trying to add does not support schematics. You can try using a different version of the package or contact the package author to add ng-add support.
我尝试使用 npm 安装依赖项:
npm i @angular/fire
这是输出:
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@angular/animations@12.0.0',
npm WARN EBADENGINE required: { node: '^12.14.1 || ^14.0.0' },
npm WARN EBADENGINE current: { node: 'v16.1.0', npm: '7.13.0' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@angular/common@12.0.0',
npm WARN EBADENGINE required: { node: '^12.14.1 || ^14.0.0' },
npm WARN EBADENGINE current: { node: 'v16.1.0', npm: '7.13.0' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@angular/compiler@12.0.0',
npm WARN EBADENGINE required: { node: '^12.14.1 || ^14.0.0' },
npm WARN EBADENGINE current: { node: 'v16.1.0', npm: '7.13.0' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@angular/compiler-cli@12.0.0',
npm WARN EBADENGINE required: { node: '^12.14.1 || ^14.0.0' },
npm WARN EBADENGINE current: { node: 'v16.1.0', npm: '7.13.0' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@angular/core@12.0.0',
npm WARN EBADENGINE required: { node: '^12.14.1 || ^14.0.0' },
npm WARN EBADENGINE current: { node: 'v16.1.0', npm: '7.13.0' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@angular/forms@12.0.0',
npm WARN EBADENGINE required: { node: '^12.14.1 || ^14.0.0' },
npm WARN EBADENGINE current: { node: 'v16.1.0', npm: '7.13.0' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@angular/platform-browser@12.0.0',
npm WARN EBADENGINE required: { node: '^12.14.1 || ^14.0.0' },
npm WARN EBADENGINE current: { node: 'v16.1.0', npm: '7.13.0' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@angular/platform-browser-dynamic@12.0.0',
npm WARN EBADENGINE required: { node: '^12.14.1 || ^14.0.0' },
npm WARN EBADENGINE current: { node: 'v16.1.0', npm: '7.13.0' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@angular/router@12.0.0',
npm WARN EBADENGINE required: { node: '^12.14.1 || ^14.0.0' },
npm WARN EBADENGINE current: { node: 'v16.1.0', npm: '7.13.0' }
npm WARN EBADENGINE }
up to date, audited 1388 packages in 6s
3 moderate severity vulnerabilities
To address all issues (including breaking changes), run:
npm audit fix --force
Run `npm audit` for details.
这是我的 package.json:
{
"name": "ng-jumbo-fire",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "~12.0.0",
"@angular/cdk": "^11.2.12",
"@angular/common": "~12.0.0",
"@angular/compiler": "~12.0.0",
"@angular/core": "~12.0.0",
"@angular/fire": "^0.0.0",
"@angular/forms": "~12.0.0",
"@angular/material": "^11.2.12",
"@angular/platform-browser": "~12.0.0",
"@angular/platform-browser-dynamic": "~12.0.0",
"@angular/router": "~12.0.0",
"rxjs": "~6.6.0",
"tslib": "^2.0.0",
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.1102.13",
"@angular/compiler-cli": "~12.0.0",
"@types/jasmine": "~3.6.0",
"@types/node": "^12.11.1",
"codelyzer": "^6.0.0",
"jasmine-core": "~3.6.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~6.3.2",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.0.3",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"protractor": "~7.0.0",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"typescript": "~4.2.4"
}
}
如何安装它。我注意到 @angular/fire 的版本是 0.0.0。文件夹 .node_modules/@angular/fire 是空的。 我将不胜感激任何帮助。
如果您查看兼容性矩阵,Angular 12 还不完全支持它。因此,您最好改用 Angular 11。
对于 Angular 12 以下与此类版本的依赖关系解决了我的问题。
安装firebase版本7.0 || 8.0 和 @angular/fire 版本 6.1.5.
package.json 文件夹依赖项应如下所示:
"dependencies": {
...
"@angular/fire": "^6.1.5",
"firebase": "^7.0 || ^8.0"
}
app.module.ts
import { AngularFireModule } from '@angular/fire';
import { AngularFirestoreModule } from '@angular/fire/firestore';
imports: [
...
AngularFireModule.initializeApp(firebaseConfig),
AngularFirestoreModule
],