gpt4 book ai didi

reactjs - 新的 React 应用程序在安装后无法立即编译

转载 作者:行者123 更新时间:2023-12-04 11:55:00 30 4
gpt4 key购买 nike

我已经使用 React Native 有一段时间了,但我想我会在网络上试用 React。所以我遵循了这个指南:https://reactjs.org/docs/create-a-new-react-app.html但使用后npx create-react-app react-try ,导航到新文件夹,然后输入 yarn start我收到此错误消息:

Failed to compile.

./src/index.js 1:60
Module parse failed: Unexpected token (1:60)
File was processed with these loaders:
* ./node_modules/@pmmmwh/react-refresh-webpack-plugin/loader/index.js
* ./node_modules/react-scripts/node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
> $RefreshRuntime$ = require('C:/Users/e096752/Documents/Cole's Git Repos/react-try/node_modules/react-refresh/runtime.js');
| $RefreshSetup$(module.id);
这是包含在 create 方法中的所有内容:
Project
Package.json
{
"name": "react-try",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-scripts": "4.0.2",
"web-vitals": "^1.0.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}

如果您需要任何其他信息,请告诉我。我到底需要做什么?

最佳答案

似乎有问题
react 脚本 4.0.2。
解决方法是在 package.json 上手动将版本更改为 4.0.1,然后运行 ​​yarn install .
那行!

关于reactjs - 新的 React 应用程序在安装后无法立即编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66127456/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com