Closed as not planned
Description
openedon Aug 20, 2024
Command
build
Is this a regression?
- Yes, this behavior used to work in the previous version
The previous version in which this bug was not present was
16
Description
if in a project you have some imported module tha includes a ,node file, vite complains that it hasn't have a loader.
X [ERROR] No loader is configured for ".node" files: node_modules/canvas/build/Release/canvas.node
node_modules/canvas/lib/bindings.js:3:25:
3 │ const bindings = require('../build/Release/canvas.node');
╵ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
It seems this could be managed inside vite.config.js, but angular doesn't have one. I tried to add one in the project root directory, but no luck
Minimal Reproduction
create a new app
ng new testpdf (include SSR)
then add ng2-pdf-viewer 10.2.2, which in turn adds pdf-js-dist 3.11.174, which adds canvas 2.11.2
in app.component.ts import pdfViewer
import { Component } from '@angular/core';
import { RouterOutlet } from '@angular/router';
import {PdfViewerModule} from 'ng2-pdf-viewer';
@Component({
selector: 'app-root',
standalone: true,
imports: [RouterOutlet, PdfViewerModule],
templateUrl: './app.component.html',
styleUrl: './app.component.scss'
})
export class AppComponent {
title = 'testpdf';
}
Add a reference to a fake pdf in app.component.html
<pdf-viewer id="pdf"></pdf-viewer>
launch ng build, and you'll get the error
Exception or Error
Prerendered 0 static routes.
Application bundle generation failed. [6.291 seconds]
X [ERROR] No loader is configured for ".node" files: node_modules/canvas/build/Release/canvas.node
node_modules/canvas/lib/bindings.js:3:25:
3 │ const bindings = require('../build/Release/canvas.node');
╵ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
### Your Environment
```text
ng version says
Angular CLI: 18.2.0
Node: 20.16.0
Package Manager: npm 10.8.1
OS: win32 x64
Angular: 18.2.0
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, platform-server
... router, ssr
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1802.0
@angular-devkit/build-angular 18.2.0
@angular-devkit/core 18.2.0
@angular-devkit/schematics 18.2.0
@schematics/angular 18.2.0
rxjs 7.8.1
typescript 5.5.4
zone.js 0.14.10
but my package.json is
{
"name": "testpdf",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test",
"serve:ssr:testssr": "node dist/testssr/server/server.mjs"
},
"private": true,
"dependencies": {
"@angular/animations": "^18.1.0",
"@angular/common": "^18.1.0",
"@angular/compiler": "^18.1.0",
"@angular/core": "^18.1.0",
"@angular/forms": "^18.1.0",
"@angular/platform-browser": "^18.1.0",
"@angular/platform-browser-dynamic": "^18.1.0",
"@angular/platform-server": "^18.1.0",
"@angular/router": "^18.1.0",
"@angular/ssr": "^18.1.4",
"express": "^4.18.2",
"ng2-pdf-viewer": "^10.2.2",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "~0.14.3"
},
"devDependencies": {
"@angular-devkit/build-angular": "^18.1.4",
"@angular/cli": "^18.1.4",
"@angular/compiler-cli": "^18.1.0",
"@types/express": "^4.17.17",
"@types/jasmine": "~5.1.0",
"@types/node": "^18.18.0",
"jasmine-core": "~5.1.0",
"karma": "~6.4.0",
"karma-chrome-launcher": "~3.2.0",
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.1.0",
"typescript": "~5.5.2"
}
}
### Anything else relevant?
_No response_
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Metadata
Assignees
Labels
No labels