npm start does not open browser tab
Asked Answered
J

1

11

I am learning angularjs 2.I want to make my first application in angularjs 2 from their official website.So i followed all from here https://angular.io/guide/quickstart. Now in step 6 I have to run a command 'npm start' in terminal.It gives me result in terminal like--

$ npm start

> [email protected] start D:\Sadiq\Res\Angularjs__2\angularQ
> tsc && concurrently "tsc -w" "lite-server"

[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: './', middleware: [ [Function], [Function] ] } }
[1] [BS] Access URLs:
[1]  -------------------------------------
[1]        Local: http://localhost:3002
[1]     External: http://192.168.2.93:3002
[1]  -------------------------------------
[1]           UI: http://localhost:3003
[1]  UI External: http://192.168.2.93:3003
[1]  -------------------------------------
[1] [BS] Serving files from: ./
[1] [BS] Watching files...
[1] [BS] File changed: app\app.component.js
[1] [BS] File changed: app\app.module.js
[1] [BS] File changed: app\main.js
[0] 12:01:51 PM - Compilation complete. Watching for file changes.

But it does not open any tab in my crome.If i enter the url it provided

'http://localhost:3002'

manually in the address bar it gives the result as expected,works fine and any changes in source file immediately cause change in the browser. problem is: I can not figure out why it is not open tab in browser automatically. Can anyone help me?

UPDATE 07 NOV 2016

Important observation is that I copied my project in another two pc. There it works as expected.when i run 'npm start' it opens tab in browser and runs the application.So there it creates no problem and works according to official angular2 tutorial site.can anyone have any idea why this is happening in my pc or my browser?

Jungjungfrau answered 6/11, 2016 at 6:22 Comment(0)
J
2

Everything looks fine, only reason might be if you there is open:false in your config. Can you try this,

create a file bs-config.js at root & add this code,

module.exports = {
  port: 5000,//custom port
  files: ['./**/*.{html,htm,css,js}'],
  open: true
};
Julissajulita answered 6/11, 2016 at 7:29 Comment(5)
"there is open:false in your config" ---not understand?Jungjungfrau
In lite-server, browser can be be prevented from opening by setting config option {open: false}. So i created a custom config bs-config.js & override the value {open: true}. apart form that i don't see any problem.Julissajulita
I cloned the same code, everything works for me as expected. check your node & npm version.Julissajulita
install node latest version,update npm done.no result.Jungjungfrau
>[1] [BS] Serving files from: ./ [1] [BS] Watching files... [1] (node:2540) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: spawn cmd ENOENT [1] (node:2540) 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.Jungjungfrau

© 2022 - 2024 — McMap. All rights reserved.