2

I am trying to include react-bootstrap js files into my project for a couple of hours. I am new to react and I will only use it for client side. I tried to include from CDN, could not get it worked (React-Bootsrap Uncaught ReferenceError: require is not defined)

This time I have downloaded packages via npm and then copy whole node_modules folder in my spring boot project.I tried to include files as below, and did not wrote any other code, just included.

<script src="${pageContext.request.contextPath}/node_modules/react/cjs/react.development.js"></script>
<script src="${pageContext.request.contextPath}/node_modules/react-dom/cjs/react-dom.development.js"></script>
<script src="${pageContext.request.contextPath}/node_modules/react-bootstrap/dist/react-bootstrap.js"></script>

However I am getting error below :

react.development.js:14 Uncaught ReferenceError: process is not defined
at react.development.js:14
(anonymous) @ react.development.js:14
react-dom.development.js:14 Uncaught ReferenceError: process is not defined
at react-dom.development.js:14
(anonymous) @ react-dom.development.js:14
 react-bootstrap.js:2218 Uncaught TypeError: Cannot read property 'Component' of undefined
at Object.exports.__esModule (react-bootstrap.js:2218)
at __webpack_require__ (react-bootstrap.js:30)
at Object.exports.__esModule (react-bootstrap.js:450)
at __webpack_require__ (react-bootstrap.js:30)
at Object.exports.__esModule (react-bootstrap.js:62)
at __webpack_require__ (react-bootstrap.js:30)
at exports.__esModule (react-bootstrap.js:50)
at react-bootstrap.js:53
at webpackUniversalModuleDefinition (react-bootstrap.js:9)
at react-bootstrap.js:10
exports.__esModule @ react-bootstrap.js:2218
__webpack_require__ @ react-bootstrap.js:30
 exports.__esModule @ react-bootstrap.js:450
__webpack_require__ @ react-bootstrap.js:30
exports.__esModule @ react-bootstrap.js:62
__webpack_require__ @ react-bootstrap.js:30
exports.__esModule @ react-bootstrap.js:50
(anonymous) @ react-bootstrap.js:53
webpackUniversalModuleDefinition @ react-bootstrap.js:9
(anonymous) @ react-bootstrap.js:10
1:85 Uncaught ReferenceError: ReactBootstrap is not defined
at 1:85
electrofant
  • 945
  • 1
  • 9
  • 16
Ali insan Soyaslan
  • 836
  • 5
  • 14
  • 33
  • 2
    Now you are just mixing things up. The code from npm is for node.js. [The `process` object in node.js](https://nodejs.org/api/process.html) – Derek 朕會功夫 Nov 29 '17 at 07:55
  • 4
    since your using it directly in the brother, you should try the react/umd/react.development.js and same for react-dom and react-bootstrap – Julien C. Nov 29 '17 at 09:21

0 Answers0