angular - ./node_modules/rxjs/_esm5/operators/index.js Angular 6 ng build --prod of / Resolve 中的错误
问题描述
我的应用程序在本地运行良好,但是当我想投入生产时,ng build --prod
出现以下错误:
知道会发生什么吗?
./node_modules/rxjs/_esm5/operators/index.js 中的错误找不到模块:错误:无法解析 /Users/.../node_modules/rxjs/_esm5/operators 中的“../internal/operators/endWith” '
包.json
{
"name": "myApp",
"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": "6.0.5",
"@angular/cdk": "^6.3.3",
"@angular/common": "^6.0.0",
"@angular/compiler": "^6.0.0",
"@angular/core": "^6.0.0",
"@angular/forms": "^6.0.0",
"@angular/http": "^6.0.0",
"@angular/material": "^6.3.3",
"@angular/platform-browser": "^6.0.0",
"@angular/platform-browser-dynamic": "^6.0.0",
"@angular/router": "^6.0.0",
"angularfire2": "^5.0.0-rc.10",
"bootstrap": "^4.1.1",
"core-js": "^2.5.4",
"firebase": "^5.0.4",
"jquery": "^3.3.1",
"popper.js": "^1.14.3",
"rxjs": "^6.0.0",
"rxjs-compat": "^6.2.2",
"zone.js": "^0.8.26"
},
"devDependencies": {
"@angular/compiler-cli": "^6.0.0",
"@angular-devkit/build-angular": "~0.6.0",
"typescript": "~2.7.2",
"@angular/cli": "~6.0.0",
"@angular/language-service": "^6.0.0",
"@types/jasmine": "~2.8.6",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"codelyzer": "~4.2.1",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~1.7.1",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~1.4.2",
"karma-jasmine": "~1.1.1",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.3.0",
"ts-node": "~5.0.1",
"tslint": "~5.9.1"
}
}
这些是我使用 RXJS 的地方
productos.service.ts
import { of } from 'rxjs';
...
getProductos() {
return of(this.productos);
}
getProducto<Producto>(id) {
return of(this.productos.find(p => p.id === id));
}
producto.resolver.service.ts
import { Injectable } from '@angular/core';
import { Router, Resolve, RouterStateSnapshot,
ActivatedRouteSnapshot } from '@angular/router';
import { Observable } from 'rxjs';
import { map, take } from 'rxjs/operators';
import { Producto, ProductosService } from './productos.service';
@Injectable({
providedIn: 'root'
})
export class ProductoResolver implements Resolve<Producto> {
constructor(private ps: ProductosService, private router: Router) { }
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot):
Observable<Producto> {
let id = route.paramMap.get('id');
return this.ps.getProducto(id).pipe(
take(1),
map(producto => {
if (producto) {
return producto;
} else { // id not found
console.error('id not found');
this.router.navigate(['/productos']);
return null;
}
})
);
}
}
解决方案
看起来问题是您的rxjs
模块已损坏。您可以尝试以下方法来修复 -
尝试
npm cache clean --force
如果它不起作用然后手动删除%appdata%\npm-cache
文件夹。从项目中删除你的 node_modules。
使用 - 重新安装所有节点模块
npm install
推荐阅读
- postgresql - 如何将 NULL 视为 MAX 日期而不是在 PostgreSQL 中忽略它?
- python - 如何从另一个文件向类添加方法?
- python - 如何拦截从我的 Linux 设备发出的所有请求?
- .net-core - V4 管道在存档 (Zip) 文件阶段失败
- python - 使用请求python在亚马逊获取联系我们页面的问题
- calculated-columns - 从具有最高值的行返回地址并对所有值列求和
- python - 让 pandas 将 hive 的 collect_list 读取为 python 列表
- sql - SQL - 框内查找框
- python - 使用 Apache 部署 Django App 时出现禁止错误
- python - 使用python从网页中提取数据