Join egghead, unlock knowledge.

Want more egghead? It's 45% off for a limited time only!

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock All Content for 45% Off

Already subscribed? Sign In

Save 45% for a limited time.

Get access to all courses and lessons on egghead today.

Autoplay

    Run the basic npm scripts

    Elijah ManorElijah Manor

    In this lesson we will examine two common scripts (start and test) that npm natively understands. We’ll define these scripts for our existing repository and show how you can run the scripts from the terminal.

    npmnpm
    Code

    Code

    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    Transcript

    Transcript

    Instructor: 00:00 Let's replace the test command that npm generated for us. We will say, "mocha." We'll provide the spec folder. Then we'll require babel-register, which will automatically compile our tests, since we're using Babel for ES2015 and beyond.

    00:18 We could open up our terminal and type "npm test" or just "npm t" to run our tests. We can see that all our tests passed.

    00:27 Let's go back and add a start script, which is another script that npm recognizes natively. For our start, we'll have it kick off the main entry point of our app, which is index.js.

    00:39 If we go back to our terminal, since this is a script that npm understands, we can just say, "npm start." Our program will execute as expected. If we look at our files, we'll see that, sure enough, the data.json was generated. We can inspect that just to make sure.

    Discuss

    Discuss