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

Npm Watch não roda

Fui tentar rodar o comando da aula após as instalações e o terminal apareceu um erro referente ao NPM Watch:

gabriela@gabriela-M16:~/Documentos/alurabank/alurabank/app$ npm start

> alurabank@1.0.0 start /home/gabriela/Documentos/alurabank/alurabank
> concurrently "npm run watch" "npm run server"

[1] 
[1] > alurabank@1.0.0 server /home/gabriela/Documentos/alurabank/alurabank
[1] > lite-server --baseDir=app
[1] 
[0] npm
[0]  
[0] ERR!
[0]  Linux 4.4.0-83-generic
[0] npm
[0]  
[0] ERR!
[0]  
[0] argv
[0]  "/usr/bin/nodejs" "/usr/bin/npm" "run" "watch"
[0] npm
[0]  
[0] ERR!
[0]  
[0] node
[0]  v6.11.0
[0] npm
[0]  
[0] ERR!
[0]  
[0] npm 
[0]  v3.10.10
[0] 
[0] npm
[0]  
[0] ERR!
[0]  missing script: watch
[0] npm
[0]  
[0] ERR!
[0]  
[0] npm
[0]  
[0] ERR!
[0]  If you need help, you may report this error at:
[0] npm ERR!     <https://github.com/npm/npm/issues>
[0] 
[0] npm
[0]  
[0] ERR!
[0]  Please include the following file with any support request:
[0] npm
[0]  
[0] ERR!
[0]      /home/gabriela/Documentos/alurabank/alurabank/npm-debug.log
[0] npm run watch exited with code 1
[1] Did not detect a `bs-config.json` or `bs-config.js` override file. Using lite-server defaults...
[1] ** browser-sync config **
[1] { injectChanges: false,
[1]   files: [ './**/*.{html,htm,css,js}' ],
[1]   watchOptions: { ignored: 'node_modules' },
[1]   server: { baseDir: 'app', middleware: [ [Function], [Function] ] } }
[1] [BS] Access URLs:
[1]  -------------------------------------
[1]        Local: http://localhost:3000
[1]     External: http://192.168.0.22:3000
[1]  -------------------------------------
[1]           UI: http://localhost:3001
[1]  UI External: http://192.168.0.22:3001
[1]  -------------------------------------
[1] [BS] Serving files from: app
[1] [BS] Watching files...
[1] 17.07.13 11:05:30 304 GET /index.html
[1] 17.07.13 11:05:30 304 GET /css/bootstrap.css
[1] 17.07.13 11:05:30 304 GET /css/bootstrap-theme.css
[1] 17.07.13 11:05:30 304 GET /lib/jquery.min.js
[1] 17.07.13 11:05:30 304 GET /lib/system.js
[1] 17.07.13 11:05:30 304 GET /js/app.js
[1] 17.07.13 11:05:30 304 GET /js/controllers/NegociacaoController.js
[1] 17.07.13 11:05:30 304 GET /js/views/MensagemView.js
[1] 17.07.13 11:05:30 304 GET /js/views/NegociacoesView.js
[1] 17.07.13 11:05:30 304 GET /js/models/Negociacoes.js
[1] 17.07.13 11:05:30 304 GET /js/models/Negociacao.js
[1] 17.07.13 11:05:30 304 GET /js/views/View.js

Tentei fazer uma alteração no arquivo .ts e como esperado ele não compilou automaticamente. Tentei instalar o npm watch manualmente(https://www.npmjs.com/package/npm-watch), mas também não compilou e não tenho certeza se é esse npm-watch que ele usa.

Alguém sabe o que pode resolver esse problema?

7 respostas

Complementando, versão do nodejs v6.11.0 e versão do npm 3.10.10

Você não criou o script watch ou escreveu errado no package.json.

Cole seu package.json. desfaça tudo que você fez para resolver o problema para não interferir.

Removi a dependencia do watch que eu havia instalado, dei um revert no meu package.json e coloquei o comando novamente copiando e colando da aula. Mesmo erro persiste no terminal:

gabriela@gabriela-M16:~/Documentos/alurabank/alurabank$ npm start

> alurabank@1.0.0 start /home/gabriela/Documentos/alurabank/alurabank
> concurrently "npm run watch" "npm run server"

[0] npm
[0]  ERR! Linux 4.4.0-83-generic
[0] npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "watch"
[0] npm ERR! node v6.11.0
[0] npm ERR! npm  v3.10.10
[0] 
[0] npm ERR! missing script: watch
[0] npm ERR! 
[0] npm ERR! If you need help, you may report this error at:
[0] npm ERR!     <https://github.com/npm/npm/issues>
[0] 
[0] npm ERR! Please include the following file with any support request:
[0] npm ERR!     /home/gabriela/Documentos/alurabank/alurabank/npm-debug.log
[0] npm run watch exited with code 1
[1] 
[1] > alurabank@1.0.0 server /home/gabriela/Documentos/alurabank/alurabank
[1] > lite-server --baseDir=app
[1] 
[1] Did not detect a `bs-config.json` or `bs-config.js` override file. Using lite-server defaults...
[1] ** browser-sync config **
[1] { injectChanges: false,
[1]   files: [ './**/*.{html,htm,css,js}' ],
[1]   watchOptions: { ignored: 'node_modules' },
[1]   server: { baseDir: 'app', middleware: [ [Function], [Function] ] } }
[1] [BS] Access URLs:
[1]  -------------------------------------
[1]        Local: http://localhost:3000
[1]     External: http://192.168.0.22:3000
[1]  -------------------------------------
[1]           UI: http://localhost:3001
[1]  UI External: http://192.168.0.22:3001
[1]  -------------------------------------
[1] [BS] Serving files from: app
[1] [BS] Watching files...
[1] 17.07.13 11:43:27 304 GET /index.html
[1] 17.07.13 11:43:27 304 GET /css/bootstrap.css
[1] 17.07.13 11:43:27 304 GET /css/bootstrap-theme.css
[1] 17.07.13 11:43:27 304 GET /lib/jquery.min.js
[1] 17.07.13 11:43:27 304 GET /lib/system.js
[1] 17.07.13 11:43:28 304 GET /js/app.js
[1] 17.07.13 11:43:28 304 GET /js/controllers/NegociacaoController.js
[1] 17.07.13 11:43:28 304 GET /js/views/MensagemView.js
[1] 17.07.13 11:43:28 304 GET /js/views/NegociacoesView.js
[1] 17.07.13 11:43:28 304 GET /js/models/Negociacoes.js
[1] 17.07.13 11:43:28 304 GET /js/models/Negociacao.js
[1] 17.07.13 11:43:28 304 GET /js/views/View.js

Meu package.json:

{
  "name": "alurabank",
  "version": "1.0.0",
  "description": "Curso do Alura de Typescript :)",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "compile": "tsc",
    "server": "lite-server --baseDir=app",
    "start": "concurrently \"npm run watch\" \"npm run server\""
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/Kappyh/TypescriptAlura.git"
  },
  "author": "Gabriela Mendes",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/Kappyh/TypescriptAlura/issues"
  },
  "homepage": "https://github.com/Kappyh/TypescriptAlura#readme",
  "devDependencies": {
    "@types/jquery": "^2.0.42",
    "concurrently": "^3.4.0",
    "lite-server": "^2.3.0",
    "typescript": "^2.3.2"
  }
}

Veja que em seu package.json não há mais a task watch. Você removeu sem querer. Era para ela ter continuado, por isso a task não é encontrada.

solução!

Olha como deve ficar a parte scripts:

"scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "compile": "tsc",
    "watch": "tsc -w",
    "server": "lite-server --baseDir=app",
    "start": "concurrently \"npm run watch\" \"npm run server\""
  },

Obrigada professor! Resolveu aqui :)

Excelente! Agora é continuar com os estudos! Sucesso e bom estudo com o TypeScript!