2
respostas

Erro no npm run start

git clone https://github.com/alura-cursos/typescript-curso-1/tree/arquivos-iniciais

Segundo o Curso de TypeScript 1 - 08 Automatizando a compilação de arquivos, eu devo rodar o "npm run start" para rodar o watch e o server.

mas esta apresentando esse erro:

$ nom run start
bash: nom: command not found

robis@Robison-I3 MINGW64 /d/Projetos/www/alura-cursos/typescript-curso-1 (main)
$ npm run start

> alurabank@1.0.0 start D:\Projetos\www\alura-cursos\typescript-curso-1 
> concurrently "npm run watch" "npm run server"

[0] Error occurred when executing command: npm run watch
[0] Error: spawn cmd.exe ENOENT
[0]     at Process.ChildProcess._handle.onexit (internal/child_process.js:268:19)
[0]     at onErrorNT (internal/child_process.js:470:16)
[0]     at processTicksAndRejections (internal/process/task_queues.js:84:21)
[1] Error occurred when executing command: npm run server
[1] Error: spawn cmd.exe ENOENT
[1]     at Process.ChildProcess._handle.onexit (internal/child_process.js:268:19)
[1]     at onErrorNT (internal/child_process.js:470:16)
[1]     at processTicksAndRejections (internal/process/task_queues.js:84:21)
[1] npm run server exited with code -4058
[0] npm run watch exited with code -4058
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! alurabank@1.0.0 start: `concurrently "npm run watch" "npm run server"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the alurabank@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\robis\AppData\Roaming\npm-cache\_logs\2021-12-10T21_35_14_363Z-debug.log

Segue o 2021-12-10T21_35_14_363Z-debug.log

0 info it worked if it ends with ok
1 verbose cli [
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   'run',
1 verbose cli   'start'
1 verbose cli ]
2 info using npm@6.14.15
3 info using node@v12.22.7
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle alurabank@1.0.0~prestart: alurabank@1.0.0
6 info lifecycle alurabank@1.0.0~start: alurabank@1.0.0
7 verbose lifecycle alurabank@1.0.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle alurabank@1.0.0~start: PATH: C:\Users\robis\AppData\Roaming\nvm\v12.22.7\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;D:\Projetos\www\alura-cursos\typescript-curso-1\node_modules\.bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Users\robis\bin;C:\php;C:\Users\robis\AppData\Roaming\nvm;C:\Program Files\nodejs;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Users\robis\AppData\Local\Microsoft\WindowsApps;C:\Users\robis\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\robis\.dotnet\tools;C:\Users\robis\AppData\Roaming\nvm;C:\Program Files\nodejs
9 verbose lifecycle alurabank@1.0.0~start: CWD: D:\Projetos\www\alura-cursos\typescript-curso-1
10 silly lifecycle alurabank@1.0.0~start: Args: [ '/d /s /c', 'concurrently "npm run watch" "npm run server"' ]
11 silly lifecycle alurabank@1.0.0~start: Returned: code: 1  signal: null
12 info lifecycle alurabank@1.0.0~start: Failed to exec start script
13 verbose stack Error: alurabank@1.0.0 start: `concurrently "npm run watch" "npm run server"`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (C:\Users\robis\AppData\Roaming\nvm\v12.22.7\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:314:20)
13 verbose stack     at ChildProcess.<anonymous> (C:\Users\robis\AppData\Roaming\nvm\v12.22.7\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:314:20)
13 verbose stack     at maybeClose (internal/child_process.js:1022:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
14 verbose pkgid alurabank@1.0.0
15 verbose cwd D:\Projetos\www\alura-cursos\typescript-curso-1
16 verbose Windows_NT 10.0.19042
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "start"
18 verbose node v12.22.7
19 verbose npm  v6.14.15
20 error code ELIFECYCLE
21 error errno 1
22 error alurabank@1.0.0 start: `concurrently "npm run watch" "npm run server"`
22 error Exit status 1
23 error Failed at the alurabank@1.0.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

Podem me ajudar nesse erro?

[ ]'s Robison

2 respostas

package.json

{
  "name": "alurabank",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "server": "lite-server --baseDir=dist",
    "start": "concurrently \"npm run watch\" \"npm run server\"",
    "compile": "tsc",
    "watch": "tsc -w"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "concurrently": "^6.0.0",
    "lite-server": "^2.6.1",
    "typescript": "^4.2.2"
  }
}

Fala amigo, lendo a documentação da lib concurrently, percebi que ele usa os argumentos com um hífen, de repente o erro é a falta de hífen. No caso seria "start": "concurrently "npm run-watch" "npm run-server"",

Tenta realizar a mudança pra ver se dá certo.