After completion of project ,i run npm run build but unable to build error showing .
npm run build
> [email protected] build
> react-scripts build
Creating an optimized production build...
Failed to compile.
Cannot read properties of undefined (reading 'includes')
i tried in my all codes but in codes no error is there.with includes.
i’m expecting to build my project completely by running npm run build.
2
Answers
There might be a pretty good chance that the
includes
method you are using on a variable/function has initially not defined or not returning any value. That’s how it’s throwing theundefined
. In such cases, You can use some sort of condition likeif
before calling theincludes
or you can declare some empty values to it initially.try to find out where you have used
.includes
inside project.and lets say you are using like this
instead of this, use