Reactjs 安装后,新React应用程序无法立即编译
我已经使用React Native有一段时间了,但我想我会尝试在web上使用React。因此,我遵循了以下指南:但在使用Reactjs 安装后,新React应用程序无法立即编译,reactjs,npm,create-react-app,yarnpkg,Reactjs,Npm,Create React App,Yarnpkg,我已经使用React Native有一段时间了,但我想我会尝试在web上使用React。因此,我遵循了以下指南:但在使用npx create react app react try、导航到新文件夹并键入warn start后,我收到以下错误消息: Failed to compile. ./src/index.js 1:60 Module parse failed: Unexpected token (1:60) File was processed with these loaders: *
npx create react app react try
、导航到新文件夹并键入warn 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方法中包含的所有内容:
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,然后运行
warn install
。
那就行了 这个问题发生在我身上,因为文件夹名称中有一个引号,删除它就解决了问题。只需遵循终端日志,问题就解决了:
我在npm命令下面使用了这个命令。我摆脱了这个问题。让我们试试这个
npm-link
实际上我就是这么做的。我本想删除这个问题,但忘了删除。谢谢你的回答,不过现在其他人都能看到了。