dcc-utils
dcc-utils copied to clipboard
Angular bug
Angular CLI: 12.0.5 Node: 14.17.1 Package Manager: npm 6.14.13 OS: win32 x64
Description
Hi, i'm trying to use dcc-utils with new empty Angular app, but i get this error :
inherits_browser.js:5 --> Uncaught TypeError: Object prototype may only be an Object or null: undefined
To Reproduce
- ng new testangular
- cd testangular
- npm install dcc-utils
- in app.component.ts include library on top of file with const { DCC } = require('dcc-utils'); // and add constructor(){ console.log(DCC.fromRaw('dcc sample test string')); }
// ng serve now will produce first errors, that you can solve editing compiling options
- npm i -D @angular-builders/custom-webpack
- edit angular.json file in the root folder:
into architect.build --->
"builder": "@angular-builders/custom-webpack:browser",
"options": {
"customWebpackConfig": {
"path": "./custom-webpack.config.js"
},
}
into architect.serve --->
"builder": "@angular-builders/custom-webpack:dev-server",
"options": {
"browserTarget": "app:build"
},
- create a file in the root of angular folder, named custom-webpack.config.js containing this code
const webpack = require('webpack');
const path = require('path');
module.exports = {
plugins: [
new webpack.ProvidePlugin({
process: 'process/browser',
}),
],
resolve: {
alias: { util$: path.resolve(__dirname, 'node_modules/util') },
//mainFields: ['browser', 'module', 'main'],
fallback: {
"fs": false,
"stream": false,
"path": false,
"crypto": false,
"assert": false,
"http": false,
"https": false,
"zlib": false,
"util": false,
"node-inspect-extracted": false,
}
}
}
- run npm i --save-dev @types/node
- in tsconfig.app -> compiler options -> "types":["node"]
- run ng serve to reproduce my error
I need help to be able to use this library in an Angular project, let me know if you need extra info, i will keep this issue update
Thank you for your precious help, Ciao
Hi, seems that Jimp and Cbor create circular dependency issue, i will try to import dcc utils directly in my Angular Project copying only the things that i needs and installing dependency package directly. Just to know if i can get this util working
i will keep this issue update, Thank you for your precious help
@ClaudioB25 ok! let me know! (sorry for my late response)
@ClaudioB25 any update?
Ciao Andrea, non sono riuscito a risolvere, temo ci siano delle incompatibilità. Ho ovviato creando un servizio apposito con node e Express e lo chiamo tramite http dalla mia app Angular. Saluti
Why close this issue if the problem wasn't really solved? Ok the workaround, but a correct integration with Angular I think could be a good thing. No ?
@mferraricloudsurfers dcc-utils is designed to run on node, not browsers. I haven't tested it yet on browsers nor built a specific distribution for them. Any contribution to make it running on browsers without problems would be appreciated!
Ciao Andrea, non sono riuscito a risolvere, temo ci siano delle incompatibilità. Ho ovviato creando un servizio apposito con node e Express e lo chiamo tramite http dalla mia app Angular. Saluti
ciao Claudio ma con questo codice si riesce a capire anche se il greenpass è scaduto?
@amammoli si, puoi controllare le date all'interno del certificato, poi ogni nazione può avere più o meno giorni di comporto a seconda delle regole nazionali. Per l'Italia sulla parte Node c'è questo https://github.com/italia/verificac19-sdk. Gli altri SDK ufficiali si trovano qua https://github.com/ministero-salute/it-dgc-verificac19-sdk-onboarding#lista-librerie
ciao Andrea grazie mille si ho verificato e funziona. Ora credo ci saranno anche aggiornamenti relativi al super grenn pass....
Il giorno gio 9 dic 2021 alle ore 10:40 Andrea Stagi < @.***> ha scritto:
@amammoli https://github.com/amammoli si puoi controllare le date all'interno del certificato, poi ogni nazione può avere più o meno giorni di comporto a seconda delle regole nazionali. Per l'Italia sulla parte Node c'è questo https://github.com/italia/verificac19-sdk. Gli altri SDK ufficiali si trovano qua https://github.com/ministero-salute/it-dgc-verificac19-sdk-onboarding#lista-librerie
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ministero-salute/dcc-utils/issues/14#issuecomment-989676535, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARCVXGG4QVZS4D6OZ6W63O3UQB2Q5ANCNFSM5FXYYPKA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.