can't resolve '@angular/animations'

博客给出了Angular动画模块的npm安装命令,即npm install @angular/animations --save,这有助于开发者在项目中引入Angular动画功能。

npm install @angular/animations --save

G:\大二\下\Angluar\LING>ng new Fu √ Which stylesheet format would you like to use? CSS [ https://developer.mozilla.org/docs/Web/CSS ] √ Do you want to enable Server-Side Rendering (SSR) and Static Site Generation (SSG/Prerendering)? Yes √ Would you like to use the Server Routing and App Engine APIs (Developer Preview) for this server application? Yes CREATE Fu/angular.json (2830 bytes) CREATE Fu/package.json (1216 bytes) CREATE Fu/README.md (1525 bytes) CREATE Fu/tsconfig.json (942 bytes) CREATE Fu/.editorconfig (331 bytes) CREATE Fu/.gitignore (629 bytes) CREATE Fu/tsconfig.app.json (508 bytes) CREATE Fu/tsconfig.spec.json (449 bytes) CREATE Fu/.vscode/extensions.json (134 bytes) CREATE Fu/.vscode/launch.json (490 bytes) CREATE Fu/.vscode/tasks.json (980 bytes) CREATE Fu/src/main.ts (256 bytes) CREATE Fu/src/index.html (301 bytes) CREATE Fu/src/styles.css (81 bytes) CREATE Fu/src/main.server.ts (271 bytes) CREATE Fu/src/server.ts (1702 bytes) CREATE Fu/src/app/app.component.html (20239 bytes) CREATE Fu/src/app/app.component.spec.ts (933 bytes) CREATE Fu/src/app/app.component.ts (290 bytes) CREATE Fu/src/app/app.component.css (0 bytes) CREATE Fu/src/app/app.config.ts (447 bytes) CREATE Fu/src/app/app.routes.ts (80 bytes) CREATE Fu/src/app/app.config.server.ts (509 bytes) CREATE Fu/src/app/app.routes.server.ts (174 bytes) CREATE Fu/public/favicon.ico (15086 bytes) - Installing packages (npm)...npm error code ERESOLVE npm error ERESOLVE unable to resolve dependency tree npm error npm error While resolving: fu@0.0.0 npm error Found: @angular/common@19.2.9 npm error node_modules/@angular/common npm error @angular/common@"^19.2.0" from the root project npm error peer @angular/common@"^19.0.0 || ^19.2.0-next.0" from @angular/ssr@19.2.11 npm error node_modules/@angular/ssr npm error @angular/ssr@"^19.2.11" from the root project npm error 3 more (@angular/platform-server, @angular/platform-browser, @angular/animations) npm error npm error Coul
05-14
app.menu.component.ts代码如下 import { Component, OnInit } from '@angular/core'; import { ToastrService } from 'ngx-toastr'; import { SystemService } from '../services/system.service'; import { LayoutService } from './service/app.layout.service'; @Component({ selector: 'app-menu', templateUrl: './app.menu.component.html' }) export class AppMenuComponent implements OnInit { model: any[] = []; constructor(public layoutService: LayoutService, private systemService: SystemService, private toastr: ToastrService ) { } ngOnInit() { this.model = [ { label: 'Menu', items: [ { label: 'Dashboard', icon: 'pi pi-fw pi-home', routerLink: ['home'] }, { label: 'Swarm', icon: 'pi pi-fw pi-share-alt', routerLink: ['swarm'] }, { label: 'Network', icon: 'pi pi-fw pi-wifi', routerLink: ['network'] }, { label: 'Settings', icon: 'pi pi-fw pi-cog', routerLink: ['settings'] }, { label: 'Logs', icon: 'pi pi-fw pi-list', routerLink: ['logs'] }, ] } ]; } public restart() { this.systemService.restart().subscribe(res => { }); this.toastr.success('Success!', 'Bitaxe restarted'); } } app.module.ts代码如下 import 'chartjs-adapter-moment'; import { CommonModule, HashLocationStrategy, LocationStrategy } from '@angular/common'; import { HttpClientModule } from '@angular/common/http'; import { NgModule } from '@angular/core'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { BrowserModule } from '@angular/platform-browser'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { ToastrModule } from 'ngx-toastr'; import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component'; import { EditComponent } from './components/edit/edit.component'; import { NetworkEditComponent } from './components/network-edit/network.edit.component'; import { HomeComponent } from './components/home/home.component'; import { LoadingComponent } from './components/loading/loading.component'; import { LogsComponent } from './components/logs/logs.component'; import { NetworkComponent } from './components/network/network.component'; import { SettingsComponent } from './components/settings/settings.component'; import { SwarmComponent } from './components/swarm/swarm.component'; import { ThemeConfigComponent } from './components/settings/theme-config.component'; import { AppLayoutModule } from './layout/app.layout.module'; import { ANSIPipe } from './pipes/ansi.pipe'; import { DateAgoPipe } from './pipes/date-ago.pipe'; import { HashSuffixPipe } from './pipes/hash-suffix.pipe'; import { PrimeNGModule } from './prime-ng.module'; import { MessageModule } from 'primeng/message'; import { TooltipModule } from 'primeng/tooltip'; import { TranslateModule, TranslateLoader, TranslateService } from '@ngx-translate/core'; // import { TranslateHttpLoader } from '@ngx-translate/http-loader'; // import { HttpClient } from '@angular/common/http'; // import { LanguageSwitcherComponent } from './components/language-switcher/language-switcher.component'; // import { APP_INITIALIZER } from '@angular/core'; export function HttpLoaderFactory(http: HttpClient) { return new TranslateHttpLoader(http, './assets/i18n/', '.json'); } export function appInitializerFactory(translate: TranslateService) { return () => { const savedLang = localStorage.getItem('userLanguage'); if (savedLang) { return translate.use(savedLang).toPromise(); } return Promise.resolve(); }; } const components = [ AppComponent, EditComponent, NetworkEditComponent, HomeComponent, LoadingComponent, NetworkComponent, SettingsComponent, LogsComponent ]; @NgModule({ declarations: [ ...components, ANSIPipe, DateAgoPipe, SwarmComponent, SettingsComponent, HashSuffixPipe, ThemeConfigComponent, LanguageSwitcherComponent // ], exports: [ // 如果其他模块需要使用该组件 LanguageSwitcherComponent ], imports: [ BrowserModule, AppRoutingModule, HttpClientModule, ReactiveFormsModule, FormsModule, ToastrModule.forRoot({ positionClass: 'toast-bottom-right', }), BrowserAnimationsModule, CommonModule, PrimeNGModule, AppLayoutModule, MessageModule, TooltipModule, TranslateModule.forRoot({ defaultLanguage: 'en', loader: { provide: TranslateLoader, useFactory: HttpLoaderFactory, deps: [HttpClient] } }) // ], providers: [ { provide: LocationStrategy, useClass: HashLocationStrategy }, { provide: APP_INITIALIZER, useFactory: appInitializerFactory, deps: [TranslateService], multi: true } ], bootstrap: [AppComponent] }) export class AppModule { } 在app.menu.component.html中使用{{ item.label | translate }}报错No pipe found with name 'translate'.ngtsc(-998004) app.menu.component.ts(6, 44): Error occurs in the template of component AppMenuComponent.怎么解决
05-28
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值