Home
Support Forums

Issue while executing "ntl dev" command for Angular

Good day everyone,

Whenever I run the command: netlify dev, 2 angular projects get loaded, one with default port 4200 and other one with the port defined in netlify.toml file. I only want to compile 1 for development. Also, when I shut down ntl dev, it shuts down the project loaded with the port in netlify.toml, but the 4200 one gets loading indefinitely and can’t use it in some time before the port closes itself or I kill it. It’s not shutting down angular properly…

netlify.toml:

[build]
  command = "ng build --output-path=dist"
  publish = "dist"
  functions = "netlify/functions"

[dev]
  command = "ng serve --open --port=4200"
  port: 3000

Also, I want to run a simple nodejs script to console.log the current branch Im working on, but its crashing, here is waht I did:

[build]
  command = "ng build --output-path=dist"
  publish = "dist"
  functions = "netlify/functions"

[dev]
  command = "node print_current_environment.js && ng serve --open"
  port = 3000

and print_current_environment.js file:

console.log(`CURRENT BRANCH: ${process.env.BRANCH}`);

Thanks for the help!

Hi @javiseeker,

That’s how Netlify Dev works. Netlify Dev waits for your SSG to start its own development server and then the requests are just proxied to the server. There’s no way to change this behaviour as that’s the basic working principle of the CLI.

Here’s how I use it generally: When I don’t need Netlify specific features like Functions, Redirects, etc., I use my app’s server directly. I don’t even run ntl dev in that case. But, when I need those features, I make sure to access my website though Netlify CLI’s port as the SSG’s port won’t have access to Netlify features.

About the shut down however, I’d assume that’s a problem. That’s definitely not expected. Could you share a test repo or something that we can test for this behaviour?

I got a workaround. I use ntl functions:serve and ng serve --open in different terminals to use both services separately. It works neatly. :slight_smile: