1
resposta

[Bug] Erro ao iniciar projeto backend

vinicius@DESKTOP-2VESIQ8:$ git clone https://github.com/alura-cursos/api-alurabooks.git fatal: destination path 'api-alurabooks' already exists and is not an empty directory. vinicius@DESKTOP-2VESIQ8:$ cd api-alurabooks vinicius@DESKTOP-2VESIQ8:/api-alurabooks$ cd api-alurabooks -bash: cd: api-alurabooks: No such file or directory vinicius@DESKTOP-2VESIQ8:/api-alurabooks$ npm run start-auth

json-server-api@1.0.0 start-auth node server.js

'\wsl.localhost\Ubuntu\home\vinicius\api-alurabooks' CMD.EXE foi iniciado tendo o caminho acima como pasta atual. Não há suporte para caminhos UNC. Padronizando para pasta do Windows. node:internal/modules/cjs/loader:1247 throw err; ^

Error: Cannot find module 'C:\Windows\server.js' at Function._resolveFilename (node:internal/modules/cjs/loader:1244:15) at Function._load (node:internal/modules/cjs/loader:1070:27) at TracingChannel.traceSync (node:diagnostics_channel:322:14) at wrapModuleLoad (node:internal/modules/cjs/loader:217:24) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:170:5) at node:internal/main/run_main_module:36:49 { code: 'MODULE_NOT_FOUND', requireStack: [] }

1 resposta

Há dois problemas aqui:

O diretório api-alurabooks já existe e não está vazio. Para resolver, você pode remover ou renomear esse diretório antes de clonar novamente:

rm -rf api-alurabooks
git clone https://github.com/alura-cursos/api-alurabooks.git

O erro Cannot find module 'C:\Windows\server.js' sugere que o comando npm run start-auth está sendo executado no Windows, mas o caminho esperado está no WSL (Linux). Para garantir que está rodando no ambiente correto:

cd ~/api-alurabooks
npm install
npm run start-auth

Se o erro persistir, verifique se o arquivo server.js realmente existe no diretório e se o json-server está instalado corretamente.