[英]React App: Failed to Compile. Module parse failed
Per this issue, it may be a problem with the react-scripts
part of your library.根据此问题,您的库的
react-scripts
部分可能存在问题。 So either use a specific, older version of create react app by running :因此,要么通过运行使用特定的旧版本 create react app:
npx create-react-app@4.0.1 my-app
Or by running CRA as is, then modifying your package.json
folder so that the react script version is specified.或者按原样运行 CRA,然后修改您的
package.json
文件夹,以便指定 react 脚本版本。
So after you run CRA, change your package.json
file like so:所以在你运行 CRA 之后,像这样更改你的
package.json
文件:
{
"name": "myapp",
...
"dependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.4.0",
"@testing-library/user-event": "^7.2.1",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-scripts": "4.0.1" // change this line to 4.0.1
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
...
}
Then make sure you rm -rf node_modules
then run npm install
to get a fresh install that removes whatever react-scripts
came by default so that you use the specific 4.0.1 version.然后确保您
rm -rf node_modules
然后运行npm install
以获得全新安装,该安装删除默认情况下的任何react-scripts
,以便您使用特定的 4.0.1 版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.