Often times when developing web applications, you need to open multiple tabs to run different scripts to start the application. This can all be done with one command
In this lesson, you will learn how to start a project and open multiple terminal tabs with one npm script.
Valid for macOS users.
Instructor: [00:00] Let's imagine you have a project with a Java back end and Webpack Dev Server. Every time you would like to start the project, you need to run these two NPM scripts in different terminal tabs. Here, we started Webpack Dev Server, and here, we started our back end. Then we need to open website in the browser.
[00:22] We're going to automate project start with NPM scripts. To solve this, we're going to use Ttab and npm-run-all packages. First, let's create new NPM script that runs command in new tab. Ttab expects command that you want to run in a new tab.
[00:46] With a navigation terminal, we can add title for each tab. Second, let's create script that opens website in the browser. Third, let's create start script that we're going to use to start the project. To run sequentially all three commands, we are using run-as command.
[01:08] That comes with the npm-run-all package. Now, let's test it. With one npm start, we are able to run two new tabs. With a back end that has Java server title, our Webpack Dev Server with a build JS title, and website in the browser.
Member comments are a way for members to communicate, interact, and ask questions about a lesson.
The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io
Be on-Topic
Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.
Avoid meta-discussion
Code Problems?
Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context
Details and Context
Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!