Filosssof
Filosssof

Reputation: 1358

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?

Upvotes: 24

Views: 14204

Answers (1)

Poul Kruijt
Poul Kruijt

Reputation: 71911

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

Upvotes: 41

Related Questions