1👍
✅
It sounds like you’re trying to include a file dashboard.js
in HTML.
If this file contains code like require('react');
then it means that you need to first compile it using a build tool that will actually find react
and bundle it together with your own code.
In case of the tutorial you’re linking, the build tool used is webpack
. Your HTML should include the file generated by webpack (index.js
, or whatever you have in output
section of webpack config), rather than dashboard.js
alone.
webpack.config.js
var config = {
entry: './main.js', # the main code of your app that require()s other files
output: {
path:'./',
filename: 'index.js', # the file you should be including in HTML
},
👤Kos
Source:stackexchange.com