I have a JavaScript file named "globalHelper.js" which looks like this:
exports.myMethod = (data) => {
// method implementation here
}
exports.myOtherMethod = () => { ... }
and so forth...
When I want to use my Helper in other files, I import it as follows:
import helper from "../Helper/globalHelper";
However, I've encountered a problem: Previously, everything worked fine when running my build script with the following command:
"build": "GENERATE_SOURCEMAP=false react-scripts build"
But now, when I run "npm run build", I receive the error message:
Attempted import error: '../Helper/globalHelper' does not contain a default export (imported as 'helper')
Strangely, when I simply start my development server using npm start, everything functions correctly.
I have tried importing the helper using
import { helper } from "../Helper/globalHelper";
, but that did not resolve the issue either.
Does anyone have a solution for this problem?