0
votes

I have integrated Mapbox GL JS (Version: 1.8.0) in a React (Version: 16.12.0) and it is working fine. But when I am trying run the build command it throws me the below error:

./node_modules/mapbox-gl/dist/mapbox-gl.css Module build failed: TypeError: Cannot read property 'toFixed' of undefined at Array.filter (<anonymous>) at Array.filter (<anonymous>) at Array.filter (<anonymous>) at Array.forEach (<anonymous>)

npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] build: react-scripts build npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] build script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] staging: env-cmd .env.staging npm run build npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] staging script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Can anybody tell me why react build command throwing the error whereas npm start command not?

2

2 Answers

0
votes

I had the same issue when building with [email protected]. I upgraded to latest (v3.4.0) which fixed the issue for me.

npm install --save react-scripts@latest

or

yarn add react-scripts@latest
0
votes

@Jonas, thanks for the reply.

I have fixed it by the following two steps:

By removing mapbox-gl.css imports from the jsx page And add the following line in the index.html page

<link href="https://api.tiles.mapbox.com/mapbox-gl-js/v1.8.0/mapbox-gl.css" rel="stylesheet" />

Thanks