lucavandro / CodiceFiscaleJS

CodiceFiscale.js is a utility library to compute and validate Italian Tax code (codice fiscale).
Creative Commons Attribution Share Alike 4.0 International
197 stars 77 forks source link

Angular 5 non funziona #17

Closed dewolft closed 5 years ago

dewolft commented 5 years ago

Ciao,

ho provato ad installare il modulo con NPM npm i codice-fiscale-js --save

ho importato la libreria come indicato : import { CodiceFiscale } from 'codice-fiscale-js';

ho chiamato la funzione come segue :

  const cf = new CodiceFiscale({
    name: "Enzo",
    surname: "Righi",
    gender: "M",
    day: 24,
    month: 7,
    year: 1957,
    birthplace: "Francia", 
    birthplaceProvincia: "EE"
});

    console.log(cf) ;

ritorna questo errore : RROR TypeError: codice_fiscale_js_1.CodiceFiscale is not a constructor at GestioneEventoComponent.CalcolaCodiceFiscale (gestione.component.ts:275) at Object.eval [as handleEvent] (GestioneEventoComponent.html:256) at handleEvent (core.js:13589) at callWithDebugContext (core.js:15098) at Object.debugHandleEvent [as handleEvent] (core.js:14685) at dispatchEvent (core.js:10004) at eval (core.js:10629) at HTMLButtonElement.eval (platform-browser.js:2628) at ZoneDelegate.invokeTask (zone.js:421) at Object.onInvokeTask (core.js:4751)

Cosa sto sbagliando?

arseniosiani commented 5 years ago

il package non espone un oggetto. prova a cambiare import { CodiceFiscale } from 'codice-fiscale-js'; con: import CodiceFiscale from 'codice-fiscale-js';

rettoua commented 5 years ago

next setup works for me: import: import { compute } from 'codice-fiscale-js' usage: const cf = compute({ name: "Enzo", surname: "Righi", gender: "M", day: 24, month: 7, year: 1957, birthplace: "Francia", birthplaceProvincia: "EE" });

gammam commented 3 years ago

sorry @lucavandro , i have the same problem

using

import  CodiceFiscale  from 'codice-fiscale-js';
const cf = new CodiceFiscale({
    name: "Enzo",
    surname: "Righi",
    gender: "M",
    day: 24,
    month: 7,
    year: 1957,
    birthplace: "Napoli"
});
console.log(cf);

returned

TypeError: codice_fiscale_js_1.default is not a constructor at Object. (/*****/fake-data-generator/test.js:4:10) at Module._compile (node:internal/modules/cjs/loader:1083:30) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1112:10) at Module.load (node:internal/modules/cjs/loader:948:32) at Function.Module._load (node:internal/modules/cjs/loader:789:14) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:72:12) at node:internal/main/run_main_module:17:47