Webpack Failed to compile

base on create-react-app ,the code as follows:

import * as THREE from 'three';

import React from 'react';

export default class Scene  extends React.Component{

    componentDidMount(){

        const scene = new THREE.Scene();

        const camera = new THREE.PerspectiveCamera( 45, window.innerWidth/window.innerHeight, 0.1, 1000 );

 

        const renderer = new THREE.WebGLRenderer();

        renderer.setSize( window.innerWidth, window.innerHeight );

        document.body.appendChild( renderer.domElement );

 

        const geometry = new THREE.BoxGeometry( 1, 1, 1 );

        const material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } );

        const cube = new THREE.Mesh( geometry, material );

        scene.add( cube );

 

        camera.position.z = 5;

 

        const animate = function () {

            requestAnimationFrame( animate );

 

            cube.rotation.x += 0.01;

            cube.rotation.y += 0.01;

 

            renderer.render( scene, camera );

        };

 

        animate();

     }

     render(){

        return null;

     }

}

when npm start .console show Failed to compile.
./node_modules/three/build/three.module.js
Module parse failed: Unexpected token (2517:25)
You may need an appropriate loader to handle this file type.
|
| this.texture = source.texture.clone();
| this.texture.image = { …this.texture.image }; // See #20328.
|
| this.depthBuffer = source.depthBuffer;

node version:v12.18.4
“three”: “^0.129.0”

Hello, I have encountered the problem you described. Have you solved it

可能是three本身的问题,我将three的版本降到128及以下就可以了