Solucionado (ver solução)
Solucionado
(ver solução)
1
resposta

[ERRO][API>NPM START] SPA's e consumo de API's

Olá;

Estou com o seguinte erro ao tentar subir o servidor da API:

Instalando dependências:

D:\DESV\WKS\api>npm install

> sqlite3@4.0.0 install D:\DESV\WKS\api\node_modules\sqlite3
> node-pre-gyp install --fallback-to-build

[sqlite3] Success: "D:\DESV\WKS\api\node_modules\sqlite3\lib\binding\node-v57-win32-x64\node_sqlite3.node" is installed via remote
npm WARN alurapic@1.0.0 No description
npm WARN alurapic@1.0.0 No repository field.

added 233 packages from 223 contributors and audited 410 packages in 12.665s
found 5 vulnerabilities (1 low, 4 moderate)
  run `npm audit fix` to fix them, or `npm audit` for details

Tentando iniciar o servidor:

D:\DESV\WKS\api>npm start

> alurapic@1.0.0 start D:\DESV\WKS\api
> node server.js

events.js:183
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE :::3000
    at Server.setupListenHandle [as _listen2] (net.js:1360:14)
    at listenInCluster (net.js:1401:12)
    at Server.listen (net.js:1485:7)
    at Object.<anonymous> (D:\DESV\WKS\api\server.js:4:24)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Function.Module.runMain (module.js:694:10)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! alurapic@1.0.0 start: `node server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the alurapic@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\f1avi\AppData\Roaming\npm-cache\_logs\2018-10-25T23_52_58_071Z-debug.log

LOG detalhado do erro:

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'start' ]
2 info using npm@6.4.1
3 info using node@v8.12.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle alurapic@1.0.0~prestart: alurapic@1.0.0
6 info lifecycle alurapic@1.0.0~start: alurapic@1.0.0
7 verbose lifecycle alurapic@1.0.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle alurapic@1.0.0~start: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;D:\DESV\WKS\api\node_modules\.bin;C:\Program Files (x86)\Intel\iCLS Client\;C:\ProgramData\Oracle\Java\javapath;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Git\cmd;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\nodejs\;C:\Users\f1avi\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Heroku\bin;C:\src\flutter\bin;C:\Users\f1avi\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\f1avi\AppData\Roaming\npm
9 verbose lifecycle alurapic@1.0.0~start: CWD: D:\DESV\WKS\api
10 silly lifecycle alurapic@1.0.0~start: Args: [ '/d /s /c', 'node server.js' ]
11 silly lifecycle alurapic@1.0.0~start: Returned: code: 1  signal: null
12 info lifecycle alurapic@1.0.0~start: Failed to exec start script
13 verbose stack Error: alurapic@1.0.0 start: `node server.js`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:301:16)
13 verbose stack     at emitTwo (events.js:126:13)
13 verbose stack     at EventEmitter.emit (events.js:214:7)
13 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at emitTwo (events.js:126:13)
13 verbose stack     at ChildProcess.emit (events.js:214:7)
13 verbose stack     at maybeClose (internal/child_process.js:915:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid alurapic@1.0.0

O que fazer?

1 resposta
solução!

Olá pessoal;

consegui corrigir o erro.

Como o próprio erro diz: Error: listen EADDRINUSE :::3000., tinha um processo usando a porta 3000

Procurando quem esta usando a porta 3000:

C:\Users\f1avi>netstat -a -o -n

Conexões ativas

  Proto  Endereço local         Endereço externo       Estado           PID
  TCP    0.0.0.0:135            0.0.0.0:0              LISTENING       668
  TCP    0.0.0.0:445            0.0.0.0:0              LISTENING       4
  TCP    0.0.0.0:1883           0.0.0.0:0              LISTENING       4696
  TCP    0.0.0.0:3000           0.0.0.0:0              LISTENING       29080
  TCP    0.0.0.0:3306           0.0.0.0:0              LISTENING       3748

Matando o processo pelo PID:

C:\Users\f1avi>taskkill /f /pid 29080
ÊXITO: o processo com PID 29080 foi finalizado.