Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run angular app from Intellij idea 2017.1?

How can I set run my angular 2 application from Intellij Idea run configuration menu?

From terminal I just put ng serve but what should I select from list of configurations from Intellij Idea?

like image 709
Filosssof Avatar asked May 16 '17 06:05

Filosssof


People also ask

How do I run an Angular project in IntelliJ?

Select File | New | Project from the main menu or click the New Project button on the Welcome screen. In the left-hand pane, choose Angular CLI. Specify the project name and the folder to create it in. In the Node Interpreter field, specify the Node.

How do I run an existing Angular project in Visual Studio?

Now open Visual Studio Code. Go to "File" > "Open Folder" and select "First-Angular-Project" from the "Desktop". Now in the "TERMINAL" run ng new Angular-Project-Demo. Whenever it prompts with something like "Would you like to add Angular routing? (y/N)" press "y" and hit "ENTER".


1 Answers

One way to do it is to create a scripts entry in your package.json, if it's not already there:

{
  ...
  "scripts": {
    "ng": "node_modules/.bin/ng",
    "start": "ng serve -o -lr=false"
  },
  ...
}

This will open the browser, and disable live-reloading (if that's what you would like.. If not, remove the -lr option). This will also use a locally installed angular-cli. This way you don't have to install it globally

Then create a new run configuration and choose npm.

  • Select your package.json
  • Select run command
  • Select the script start

Make sure your node interpreter is set, and press ok.

Now you can use the green button to run your configuration :)

You can also just right-click on your package.json, and select show npm scripts. This will open a window, where you can double click the 'start' script you just created

like image 106
Poul Kruijt Avatar answered Oct 07 '22 20:10

Poul Kruijt