Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
311 views
in Technique[技术] by (71.8m points)

javascript - React - Module parse failed: Unexpected token

I decided to install the npm package react-radio-buttons after installing and applying on my component gives an error:

./node_modules/react-radio-buttons/index.jsx 80:6
module parse failed: Unexpected token (80:6)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|     const style = horizontal ? { display: 'inline-flex', width: '100%' } : {};
|     return (
>       <div style={style} { ...props}>
|         {
|           children.map((c, i) => this.renderChild(c, i, i === checkedIndex)))

I suppose the problem may be related to package.json but I don't know how to solve the problem. Before I provide the package file, I want to warn a lot of properties inside the dependencies object, I will cut everything out and leave only "react-radio-buttons": "^ 1.2.2", the actual package behind which the error occurs.

package.json

{
  "name": "my-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react-radio-buttons": "^1.2.2",
  },
  "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"
    ]
  }
}
question from:https://stackoverflow.com/questions/65915509/react-module-parse-failed-unexpected-token

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...