Thursday 1 June 2017

var express = require('express') - Cannot read property 'prototype' of undefined

I am new to Express, so forgive me if this is a simple one. I have a React project and I am trying to add Express to it. I have added a .js file that begins with the following line to import express:

var express = require('express');

However, this throws an error.

Error

request.js:31 Uncaught TypeError: Cannot read property 'prototype' of undefined
    at Object.<anonymous> (request.js:31)
    at __webpack_require__ (bootstrap 2c79a52…:555)
    at fn (bootstrap 2c79a52…:86)
    at Object.<anonymous> (express.js:20)
    at __webpack_require__ (bootstrap 2c79a52…:555)
    at fn (bootstrap 2c79a52…:86)
    at Object.<anonymous> (index.js:11)
    at __webpack_require__ (bootstrap 2c79a52…:555)
    at fn (bootstrap 2c79a52…:86)
    at Object.<anonymous> (myNewFile.js:1)

Note: line 1 of myNewFile.js is var express = require('express');

I did try npm install express so I should have access to express and it should be up to date, but it seems that I still get this error.

How can I resolve this error and why is it occurring?

Thanks.



via Rbar

No comments:

Post a Comment