我是Express的新手,所以請原諒我,如果這是簡單的。我有一個React項目,我正在嘗試添加Express。我添加了一個.js文件,該文件以下列行開始,以導入快車:var express = require('express') - 無法讀取未定義的屬性'prototype'
var express = require('express');
但是,這會引發錯誤。
錯誤
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)
注:行
我曾嘗試npm install express
所以我應該有機會來表達,它應該是最新的,但它似乎我仍然得到這個錯誤。
如何解決此錯誤,爲什麼會發生?
謝謝。
可能的重複https://stackoverflow.com/questions/38191695/express-uncaught-typeerror-cannot-read-property-prototype-of-undefined-req –
*當*出現錯誤?它在你的package.json中嗎?你如何捆綁所有這些?我的意思是,Express是後端,ReactJS是前端 - 爲什麼在同一個項目中一起? –
可能重複https://stackoverflow.com/questions/44292704/cannot-find-module-fs-using-simple-json-loader – oklas