Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

error: cannot find module express

My issue: I'm receiving "Error: Cannot Find Module 'express'" when I execute the code below using Command Prompt on my machine.

//Require https module
const https = require('https');
//Require Basic Auth
const app = require('express')()
const basicAuth = require('express-basic-auth')

app.use(basicAuth({
    users: { 'username': 'password' }
}))

const request = https.get('https://frontier.sandbox.beamery.com/v1/auth', response => {
      let body = "";
  response.on('data', data => {
    body += data.toString();
});

  response.on('end', () => {
     console.log(body);
              })

});

I've ran npm install express -g I've ran npm install express-basic-auth -g

I'm using the live-server npm

If I execute npm list -g --depth=0 I get the following returned: +-- express@4.17.1 `-- live-server@1.2.1

I would assume 'express' could be found since I installed both of the npm's. Does anyone know what my issue could be? Thanks!