Solucionado (ver solução)
Solucionado
(ver solução)
2
respostas

Não consigo identificar o problema

Ao executar o arquivo no prompt de comando aparece o seguinte erro:

`C:\Users\Denise\alura-node>npm run cli validar

lib-markdown@1.0.0 cli C:\Users\Denise\alura-node node cli.js ./arquivos/texto1.md "validar"

(node:10348) ExperimentalWarning: The ESM module loader is experimental. (node:10348) UnhandledPromiseRejectionWarning: Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only file and data URLs are supported by the default ESM loader at Loader.defaultResolve [as resolve] (internal/modules/esm/resolve.js:698:11) at Loader.resolve (internal/modules/esm/loader.js:97:40) at Loader.getModuleJob (internal/modules/esm/loader.js:243:28) at ModuleWrap. (internal/modules/esm/modulejob.js:47:40) at link (internal/modules/esm/module_job.js:46:36) (node:10348) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 6) (node:10348) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.`

2 respostas
solução!

Isso é porque o node está atualizado e na importação que a professora faz com o require é a forma antiga, agora a nova sintaxe utilizada é o exports ou o import,então no arquivo http-validacao.js, substitua na primeira linha do arquivo: const fetch = require('node-fetch');

POR, const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));

Obrigado

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software