[英]Important npm install @babel/plugin-transform-react-jsx is not working
Hello sorry for a problems, but its my first post.你好抱歉出现问题,但这是我的第一篇文章。 I have problem during npm start, and that is a message:
我在 npm start 期间遇到问题,这是一条消息:
/Users/hp/Desktop/Wszystkie Projekty/ravenous/src/components/BusinessList/BusinessList.js
SyntaxError: C:\Users\hp\Desktop\Wszystkie Projekty\ravenous\src\components\BusinessList\BusinessList.js: Support for the experimental syntax 'jsx' isn't currently enabled (10:7):
8 | render(){
9 | return (
> 10 | <div className="BusinessList">
| ^
11 | <Business />
12 | <Business />
13 | <Business />
Add @babel/preset-react (https://git.io/JfeDR) to the 'presets' section of your Babel config to enable transformation.
If you want to leave it as-is, add @babel/plugin-syntax-jsx (https://git.io/vb4yA) to the 'plugins' section to enable parsing.
package.json包.json
{
"name": "ravenous",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
"react": "^16.14.0",
"react-dom": "^16.14.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@babel/core": "^7.12.3",
"@babel/plugin-syntax-jsx": "^7.12.1",
"@babel/plugin-transform-react-jsx": "^7.12.1",
"@babel/preset-react": "^7.12.1",
"@testing-library/jest-dom": "^4.2.4",
"react-script": "^2.0.5",
"react-scripts": "3.4.4"
}
}
I made steps,that you suggested, and also try to update some plugins.我做了你建议的步骤,并尝试更新一些插件。 It looks like folder with transform-jsx is properly installed in @babel, but still the same problem...
看起来带有transform-jsx的文件夹已正确安装在@babel中,但仍然是同样的问题......
I will add also BusinessList file:我还将添加 BusinessList 文件:
import React from 'react';
import './BusinessList.css';
import Business from '../Business/Business';
import App from '/Users/hp/Desktop/Wszystkie Projekty/ravenous/src/components/App/App';
class BusinessList extends React.Component{
render(){
return (
<div className="BusinessList">
<Business />
<Business />
<Business />
<Business />
<Business />
<Business />
</div>
);
}
}
export default BusinessList;
Any ideas ?有任何想法吗 ? Also when im installing npm plugins it seems that i always have these message in terminal: 74 packages are looking for funding run
npm fund
for details :此外,当我安装 npm 插件时,我似乎总是在终端中收到以下消息:74 个包正在寻找资金运行
npm fund
以获取详细信息:
$npm fund
ravenous@0.1.0
+-- https://opencollective.com/babel
| `-- @babel/core@7.12.3, @babel/core@7.9.0
+-- https://github.com/sponsors/ljharb
| `-- resolve@1.18.1, is-core-module@2.0.0, resolve@1.15.0, object.assign@4.1.1, es-abstract@1.18.0-next.1, has-symbols@1.0.1, es-to-primitive@1.2.1, is-callable@1.2.2, is-regex@1.1.1, object-inspect@1.8.0, string.prototype.trimend@1.0.2, string.prototype.trimstart@1.0.2, is-date-object@1.0.2, is-symbol@1.0.3, object.values@1.1.1, util.promisify@1.0.1, es-abstract@1.17.7, object.getownpropertydescriptors@2.1.0, array-includes@3.1.1, array.prototype.flat@1.2.3, is-string@1.0.5, object.fromentries@2.0.2, string.prototype.matchall@4.0.2, regexp.prototype.flags@1.3.0, side-channel@1.0.3, deep-equal@1.1.1, object-is@1.1.3
+-- https://opencollective.com/core-js
| `-- core-js-pure@3.6.5, core-js-compat@3.6.5, core-js@3.6.5
+-- https://github.com/chalk/ansi-styles?sponsor=1
| `-- ansi-styles@4.3.0
+-- https://opencollective.com/typescript-eslint
| `-- @typescript-eslint/eslint-plugin@2.34.0, @typescript-eslint/parser@2.34.0, @typescript-eslint/experimental-utils@2.34.0, @typescript-eslint/typescript-estree@2.34.0
+-- https://opencollective.com/webpack
| `-- css-loader@3.4.2, sass-loader@8.0.2, terser-webpack-plugin@2.3.8, webpack@4.42.0, schema-utils@2.7.1
+-- https://opencollective.com/eslint
| `-- eslint@6.8.0
+-- https://tidelift.com/funding/github/npm/browserslist
| `-- browserslist@4.14.5, browserslist@4.10.0
+-- https://github.com/sponsors/fb55
| `-- css-what@3.4.2, domelementtype@2.0.2
+-- https://github.com/fb55/entities?sponsor=1
| `-- entities@2.1.0
+-- https://github.com/sponsors/mysticatea
| `-- regexpp@3.1.0, eslint-utils@2.1.0
+-- https://github.com/sponsors/isaacs
| `-- glob@7.1.6
+-- https://github.com/sponsors/sindresorhus
| `-- p-limit@2.3.0, parse-json@5.1.0, globals@12.4.0, strip-json-comments@3.1.1, ansi-escapes@4.3.1, figures@3.2.0, type-fest@0.11.0, onetime@5.1.2, open@7.3.0, is-docker@2.1.1, make-dir@3.1.0, pretty-bytes@5.4.1
+-- https://github.com/sponsors/epoberezkin
| `-- ajv@6.12.6
+-- https://opencollective.com/postcss/
| `-- postcss@7.0.35, postcss-load-config@2.1.2
+-- https://github.com/chalk/chalk?sponsor=1
| `-- chalk@4.1.0
+-- https://github.com/sponsors/feross
| `-- safe-buffer@5.2.1
+-- https://www.patreon.com/feross
| `-- safe-buffer@5.2.1
+-- https://feross.org/support
| `-- safe-buffer@5.2.1
+-- https://github.com/sponsors/wooorm
| `-- vendors@1.0.4
+-- https://tidelift.com/funding/github/npm/autoprefixer
| `-- autoprefixer@9.8.6
+-- https://github.com/sponsors/jonschlinkert
| `-- picomatch@2.2.2
+-- https://github.com/avajs/find-cache-dir?sponsor=1
| `-- find-cache-dir@3.3.1
+-- https://tidelift.com/subscription/pkg/npm-loglevel?utm_medium=referral&utm_source=npm_fund
| `-- loglevel@1.7.0
`-- https://github.com/sponsors/RubenVerborgh
`-- follow-redirects@1.13.0
package.json
entry for @babel/plugin-transform-react-jsx
points to the place that is going to be installed. @babel/plugin-transform-react-jsx
package.json
条目指向要安装的位置。 That's probably why you get "too many symbolic links".这可能就是你得到“太多符号链接”的原因。
You also have a very old version of babel-plugin-transform-react-jsx
and it doesn't match with the @babel/core
version.您还有一个非常旧版本的
babel-plugin-transform-react-jsx
,它与@babel/core
版本不匹配。
babel-plugin-transform-react-jsx
from package.json
.package.json
删除babel-plugin-transform-react-jsx
。@babel/plugin-transform-react-jsx
from devDependencies
in package.json
.package.json
devDependencies
中删除@babel/plugin-transform-react-jsx
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.