Closed thovo closed 6 years ago
The issue is that one of your libraries manipulates a <canvas>
element, which is not supported by the SSR DOM implementation (Domino). You need to move whatever library is responsible for this into a browser-only part of your app so that it doesn't throw errors on the server.
It's likely this doesn't impact the initial view, so doing this shouldn't impact the overall usability of your app.
I think the root cause is not the canvas, because I removed it and also the component used it but it didn't help.
Then a better avenue for support would be StackOverflow or Gitter. The main repo works on clean install, any added functionality is out of scope for filing issues here.
Can you give me gitter link? Many thanks!
I'm getting the same error from ng2-charts (which I see you're also using). The problem seems to be here:
BaseChartDirective.prototype.ngOnInit = function () {
this.ctx = this.element.nativeElement.getContext('2d');
this.cvs = this.element.nativeElement;
this.initFlag = true;
if (this.data || this.datasets) {
this.refresh();
}
};
and particularly, here:
this.ctx = this.element.nativeElement.getContext('2d');
In my case, wrapping the canvas element and displaying it conditionally only if the platform is browser seems to be avoiding the error, at least.
The template:
<div style="display: block" *ngIf="isBrowser">
<canvas baseChart
[datasets]="datasets"
[options]="barChartOptions"
[legend]="barChartLegend"
[chartType]="'bar'"
[colors]="statisticsService.colors"
(chartHover)="chartHovered($event)"
(chartClick)="chartClicked($event)">
</canvas>
</div>
The typescript file:
constructor(@Inject(PLATFORM_ID) private platformId: Object) {
this.isBrowser = isPlatformBrowser(this.platformId);
}
If You want to run fabric.js in angular 7.
Add fabric.js in your assets folder.
Add path to fabric.js in angular.json
"scripts": [ "./src/styles/fabric.js" ]
Add following line to the component in which you are using.
declare var fabric: any;
Add following line to server.ts / prrender.ts
import * as fabric from './src/styles/fabric.js';
global['fabric'] = fabric;
I have same error
throw new Error("NotYetImplemented");
^
Error: NotYetImplemented
at HTMLCanvasElement.exports.nyi (/Users/apple/Documents/honadon/temporaryquickapp/Honadon-master/Source/XonadonUz/ClientApp/dist/server.js:96152:9)
at Object.<anonymous> (/Users/apple/Documents/honadon/temporaryquickapp/Honadon-master/Source/XonadonUz/ClientApp/dist/server.js:299218:48)
at __webpack_require__ (/Users/apple/Documents/honadon/temporaryquickapp/Honadon-master/Source/XonadonUz/ClientApp/dist/server.js:20:30)
at Object.hasImageData (/Users/apple/Documents/honadon/temporaryquickapp/Honadon-master/Source/XonadonUz/ClientApp/dist/server.js:298931:20)
at __webpack_require__ (/Users/apple/Documents/honadon/temporaryquickapp/Honadon-master/Source/XonadonUz/ClientApp/dist/server.js:20:30)
at Object.<anonymous> (/Users/apple/Documents/honadon/temporaryquickapp/Honadon-master/Source/XonadonUz/ClientApp/dist/server.js:298922:17)
at __webpack_require__ (/Users/apple/Documents/honadon/temporaryquickapp/Honadon-master/Source/XonadonUz/ClientApp/dist/server.js:20:30)
at Module.<anonymous> (/Users/apple/Documents/honadon/temporaryquickapp/Honadon-master/Source/XonadonUz/ClientApp/dist/server.js:298368:78)
at __webpack_require__ (/Users/apple/Documents/honadon/temporaryquickapp/Honadon-master/Source/XonadonUz/ClientApp/dist/server.js:20:30)
at Module.<anonymous> (/Users/apple/Documents/honadon/temporaryquickapp/Honadon-master/Source/XonadonUz/ClientApp/dist/server.js:291645:76)
I cant find solution
Hi everyone,
I am not sure this is the right place to ask the question regarding my issue. If not, please accept my apology and remove it!
I were following the guide to implement Angular Universal for my application. Everything worked out well until the last command
node dist/server.js
throw an errorError: NotYetImplemented
The full traceback is here:
The current version of the packages in my application can be viewed here in package.json:
webpack.server.config.js
Anyone saw the same problem can give me some insights? Many thanks!