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?

2 Answers 2

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
};
Sign up to request clarification or add additional context in comments.

5 Comments

"there is open:false in your config" ---not understand?
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.
I cloned the same code, everything works for me as expected. check your node & npm version.
install node latest version,update npm done.no result.
>[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.
0

For the angular project you can also open using ng serve with --open flag to open the browser automatically.

ng serve --open

Reference: https://stackoverflow.com/a/42943826/6908282

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.