It should have little to do with the configuration version number in dependencies
. Some people say that it should be changed to the following version number
"ol": "^6.4.0",
but it doesn't solve the problem.
The final solution is to change the reference method of ol/source
,
change to
import XYZ from 'ol/source/XYZ';
import sourceVector from 'ol/source/Vector';