我的应用程序在本地运行良好,但是当我想使用ng build --prod
进行生产时,出现以下错误:
有什么想法吗?
./ node_modules / rxjs / _esm5 / operators / index.js中的错误 找不到模块:错误:无法解析/Users/.../node_modules/rxjs/_esm5/operators中的'../ internal / operators / endWith'
package.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;
}
})
);
}
}
答案 0 :(得分:8)
问题似乎出在您的#include <QApplication>
#include <QMainWindow>
#include <qwt_plot.h>
#include <qwt_plot_curve.h>
#include <qwt_plot_zoomer.h>
int main( int argc, char **argv )
{
QApplication a( argc, argv );
a.setStyleSheet("QwtPlotCanvas { background: black; } ");
QwtPlot * plot = new QwtPlot();
plot->setAxisAutoScale(QwtPlot::xBottom);
plot->setAxisAutoScale(QwtPlot::yLeft);
QwtPlotZoomer *zoomer;
zoomer = new QwtPlotZoomer( QwtPlot::xBottom, QwtPlot::yLeft, plot->canvas() );
zoomer->setRubberBandPen(QPen(Qt::white));
// create data
std::vector<double> x(100);
std::vector<double> y1(x.size());
for (size_t i = 0; i< x.size(); ++i) { x[i] = int(i)-50; }
for (size_t i = 0; i< y1.size(); ++i) {
y1[i] = i*i;
}
// first curve
QwtPlotCurve *curve = new QwtPlotCurve();
curve->setPen(Qt::white);
curve->setRawSamples(&x[0], &y1[0], x.size());
curve->attach( plot );
plot->replot();
QMainWindow window;
window.setCentralWidget(plot);
window.resize(800, 600);
window.show();
return a.exec();
}
模块损坏了。您可以尝试以下解决方法-
尝试rxjs
如果不起作用,请手动删除npm cache clean --force
文件夹。
从项目中删除您的node_modules。
使用-%appdata%\npm-cache
答案 1 :(得分:0)
当您从较低的位置迁移到较高的位置时,将发生此错误 全局版本的角度版本,但本地版本 和以前一样
或
RXJS可能由于某些原因而损坏
或
您可以安装新版本的rxjs,但不清除缓存使用 接下来的步骤,它可以解决您的问题
步骤1 :删除缓存npm cache clean --force
步骤2 :删除节点模块rm -rf node_modules
(可以手动删除)
步骤3 :再次安装节点模块npm install
或npm i