cody-greene / node-rabbitmq-client

RabbitMQ (0-9-1) client library with auto-reconnect & zero dependencies
MIT License
128 stars 9 forks source link

TypeError: class heritage node_stream_1.Writable is not an object or null #55

Closed Fipschen closed 4 months ago

Fipschen commented 4 months ago

Hi there,

I try to connect my angular app to the rabbitmq server (it's an raspberry pi in local network). When open the component with the api, I'll get the error in title: TypeError: class heritage node_stream_1.Writable is not an object or null The following is the api service: `import { Injectable } from '@angular/core'; import { Connection } from 'rabbitmq-client';

@Injectable({ providedIn: 'root' }) export class OfflineAmpelControllerApiService {

constructor() { console.log("Try to connect..."); let rabbit = new Connection('amqp://username:password@raspi:5672');

rabbit.on('error', (err) => {
  console.log('RabbitMQ connection error', err)
});
rabbit.on('connection', () => {
  console.log('Connection successfully (re)established')
});

} }`

my angular.json: { "$schema": "./node_modules/@angular/cli/lib/config/schema.json", "version": 1, "newProjectRoot": "projects", "projects": { "AngDev": { "projectType": "application", "schematics": { "@schematics/angular:component": { "standalone": false }, "@schematics/angular:directive": { "standalone": false }, "@schematics/angular:pipe": { "standalone": false } }, "root": "", "sourceRoot": "src", "prefix": "app", "architect": { "build": { "builder": "@angular-devkit/build-angular:application", "options": { "outputPath": "dist/ang-dev", "index": "src/index.html", "browser": "src/main.ts", "polyfills": [ "zone.js" ], "tsConfig": "tsconfig.app.json", "assets": [ "src/favicon.ico", "src/assets", ], "styles": [ "@angular/material/prebuilt-themes/deeppurple-amber.css", "src/styles.css" ] "server": "src/main.server.ts", "prerender": false, "ssr": false }, "configurations": { "production": { "budgets": [ { "type": "initial", "maximumWarning": "500kb", "maximumError": "1mb" }, { "type": "anyComponentStyle", "maximumWarning": "2kb", "maximumError": "4kb" } ], "outputHashing": "all" }, "development": { "optimization": false, "extractLicenses": false, "sourceMap": true } }, "defaultConfiguration": "production" }, "serve": { "builder": "@angular-devkit/build-angular:dev-server", "configurations": { "production": { "buildTarget": "AngDev:build:production", "proxyConfig": "src/proxy.conf.json" }, "development": { "buildTarget": "AngDev:build:development", "proxyConfig": "src/proxy.conf.json" } }, "defaultConfiguration": "development" }, "extract-i18n": { "builder": "@angular-devkit/build-angular:extract-i18n", "options": { "buildTarget": "AngDev:build" } }, "test": { "builder": "@angular-devkit/build-angular:karma", "options": { "polyfills": [ "zone.js", "zone.js/testing" ], "tsConfig": "tsconfig.spec.json", "assets": [ "src/favicon.ico", "src/assets" ], "styles": [ "@angular/material/prebuilt-themes/deeppurple-amber.css", "src/styles.css" ] } } }, "i18n": { "sourceLocale": "de-DE" } } }, "cli": { "analytics": "58f39bb4-9245-41d2-9246-110bfd2ba6bd" } }

and package.json: { "name": "ang-dev", "version": "0.0.0", "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "watch": "ng build --watch --configuration development", "test": "ng test", "serve:ssr:AngDev": "node dist/ang-dev/server/server.mjs" }, "private": true, "dependencies": { "@angular/animations": "^17.0.5", "@angular/cdk": "^17.0.5", "@angular/common": "^17.0.5", "@angular/compiler": "^17.0.5", "@angular/core": "^17.0.5", "@angular/forms": "^17.0.5", "@angular/material": "^17.0.5", "@angular/material-moment-adapter": "^17.2.0", "@angular/platform-browser": "^17.0.5", "@angular/platform-browser-dynamic": "^17.0.5", "@angular/platform-server": "^17.0.5", "@angular/router": "^17.0.5", "@angular/ssr": "^17.0.4", "cryptojs": "^2.5.3", "express": "^4.18.2", "jschardet": "^3.1.2", "localstorage-polyfill": "^1.0.1", "primeicons": "^6.0.1", "rabbitmq-client": "^4.6.0", "rxjs": "~7.8.0", "set-interval-async": "^3.0.3", "tslib": "^2.3.0", "zone.js": "~0.14.2" }, "devDependencies": { "@angular-devkit/build-angular": "^17.1.0", "@angular/cli": "^17.1.0", "@angular/compiler-cli": "^17.1.0", "@types/cryptojs": "^3.1.33", "@types/express": "^4.17.17", "@types/jasmine": "~5.1.0", "@types/mime-types": "^2.1.4", "@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.2.2" } }

Can someone tell me, how I'll get it working?

Thank you very much

Fipsi

cody-greene commented 4 months ago

This library is for nodejs, server-side only.

-------- Original Message -------- On 7/6/24 7:45 AM, Fipschen wrote:

Hi there,

I try to connect my angular app to the rabbitmq server (it's an raspberry pi in local network). When open the component with the api, I'll get the error in title: TypeError: class heritage node_stream_1.Writable is not an object or null The following is the api service: `import { Injectable } from @.***/core'; import { Connection } from 'rabbitmq-client';

@.***(https://github.com/Injectable)({ providedIn: 'root' }) export class OfflineAmpelControllerApiService {

constructor() { console.log("Try to connect..."); let rabbit = new @.***:5672');

rabbit.on('error', (err) => { console.log('RabbitMQ connection error', err) }); rabbit.on('connection', () => { console.log('Connection successfully (re)established') });

} }`

my angular.json: { "$schema": @./cli/lib/config/schema.json", "version": 1, "newProjectRoot": "projects", "projects": { "AngDev": { "projectType": "application", "schematics": { @./angular:component": { "standalone": false }, @./angular:directive": { "standalone": false }, @./angular:pipe": { "standalone": false } }, "root": "", "sourceRoot": "src", "prefix": "app", "architect": { "build": { "builder": @./build-angular:application", "options": { "outputPath": "dist/ang-dev", "index": "src/index.html", "browser": "src/main.ts", "polyfills": [ "zone.js" ], "tsConfig": "tsconfig.app.json", "assets": [ "src/favicon.ico", "src/assets", ], "styles": [ @./material/prebuilt-themes/deeppurple-amber.css", "src/styles.css" ] "server": "src/main.server.ts", "prerender": false, "ssr": false }, "configurations": { "production": { "budgets": [ { "type": "initial", "maximumWarning": "500kb", "maximumError": "1mb" }, { "type": "anyComponentStyle", "maximumWarning": "2kb", "maximumError": "4kb" } ], "outputHashing": "all" }, "development": { "optimization": false, "extractLicenses": false, "sourceMap": true } }, "defaultConfiguration": "production" }, "serve": { "builder": @./build-angular:dev-server", "configurations": { "production": { "buildTarget": "AngDev:build:production", "proxyConfig": "src/proxy.conf.json" }, "development": { "buildTarget": "AngDev:build:development", "proxyConfig": "src/proxy.conf.json" } }, "defaultConfiguration": "development" }, "extract-i18n": { "builder": @./build-angular:extract-i18n", "options": { "buildTarget": "AngDev:build" } }, "test": { "builder": @./build-angular:karma", "options": { "polyfills": [ "zone.js", "zone.js/testing" ], "tsConfig": "tsconfig.spec.json", "assets": [ "src/favicon.ico", "src/assets" ], "styles": [ @./material/prebuilt-themes/deeppurple-amber.css", "src/styles.css" ] } } }, "i18n": { "sourceLocale": "de-DE" } } }, "cli": { "analytics": "58f39bb4-9245-41d2-9246-110bfd2ba6bd" } }

and package.json: { "name": "ang-dev", "version": "0.0.0", "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "watch": "ng build --watch --configuration development", "test": "ng test", "serve:ssr:AngDev": "node dist/ang-dev/server/server.mjs" }, "private": true, "dependencies": { @./animations": "^17.0.5", @./cdk": "^17.0.5", @./common": "^17.0.5", @./compiler": "^17.0.5", @./core": "^17.0.5", @./forms": "^17.0.5", @./material": "^17.0.5", @./material-moment-adapter": "^17.2.0", @./platform-browser": "^17.0.5", @./platform-browser-dynamic": "^17.0.5", @./platform-server": "^17.0.5", @./router": "^17.0.5", @./ssr": "^17.0.4", "cryptojs": "^2.5.3", "express": "^4.18.2", "jschardet": "^3.1.2", "localstorage-polyfill": "^1.0.1", "primeicons": "^6.0.1", "rabbitmq-client": "^4.6.0", "rxjs": "~7.8.0", "set-interval-async": "^3.0.3", "tslib": "^2.3.0", "zone.js": "~0.14.2" }, "devDependencies": { @./build-angular": "^17.1.0", @./cli": "^17.1.0", @./compiler-cli": "^17.1.0", @./cryptojs": "^3.1.33", @./express": "^4.17.17", @./jasmine": "~5.1.0", @./mime-types": "^2.1.4", @.***/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.2.2" } }

Can someone tell me, how I'll get it working?

Thank you very much

Fipsi

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>

Fipschen commented 4 months ago

Ouh dam it.. thank you, I didn't get this.