Ao tentar importar a classe para o arquivo index.JS recebi o erro abaixo.
[Running] node "/home/nsouza/Projetos/bit-bank/index.js"
(node:4805) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
/home/nsouza/Projetos/bit-bank/index.js:1
import {Cliente} from "./Cliente.js"
^^^^^^
SyntaxError: Cannot use import statement outside a module
at wrapSafe (internal/modules/cjs/loader.js:1172:16)
at Module._compile (internal/modules/cjs/loader.js:1220:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1277:10)
at Module.load (internal/modules/cjs/loader.js:1105:32)
at Function.Module._load (internal/modules/cjs/loader.js:967:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
at internal/main/run_main_module.js:17:47
[Done] exited with code=1 in 0.124 seconds
abaixo minhas classes
export class Cliente{
nome;
cpf;
}
export class ContaCorrente{
agencia;
saldo = 0;
sacar(valor){
if (this.Saldo >= valor){
this.saldo -= valor;
return valor;
}
}
depositar(valor){
if(valor <= 0 )return;
this.saldo += valor;
}
}
{
"name": "bit-bank",
"version": "1.0.0",
"description": "Projeto bit-bank para seu clientes",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Nilo",
"license": "ISC",
"type": "module"
}