When I install react-bootstrap in my CRA react app, and try to import any component such as:
import Form from "react-bootstrap";
I get this error:
Failed to compile.
./node_modules/react-bootstrap/esm/SplitButton.js
Module parse failed: Unexpected token (101:2)
You may need an appropriate loader to handle this file type.
| renderMenuOnMount,
| rootCloseEvent,
| ...props
| }, ref) => /*#__PURE__*/_jsxs(Dropdown, {
| ref: ref,
My package.json looks like this:
{
"name": "component-3",
"version": "0.1.1",
"private": true,
"dependencies": {
"#testing-library/jest-dom": "^5.15.0",
"#testing-library/react": "^11.2.7",
"#testing-library/user-event": "^12.8.3",
"axios": "^0.23.0",
"bootstrap": "^5.1.3",
"dotenv": "^10.0.0",
"firebase": "^8.10.0",
"firebase-admin": "^9.12.0",
"react": "^17.0.2",
"react-bootstrap": "^2.0.2",
"react-color-extractor": "^1.1.2",
"react-dom": "^17.0.2",
"react-firebase-hooks": "^3.0.4",
"react-google-button": "^0.7.2",
"react-router-dom": "^5.2.0",
"react-scripts": "^1.1.5",
"react-select": "^5.2.1",
"web-vitals": "^1.1.2"
},
"scripts": {
"start": "set NODE_ENV=dev && CHOKIDAR_USEPOLLING=true 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 op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
I want to use components such as Form in my app. I have used react-bootstrap with CRA before with no issues.
I have seen similar posts but none with this exact issue.
Any idea what might be causing this?
Related
I got this project from repo and cloned it using git clone
then I go to the directory in which I cloned it.
next I went to install the project using NPM install command and these errors occur:-
here is the JSON file
{
"name": "grocery-storeowner-frontend",
"version": "0.1.0",
"private": true,
"dependencies": {
"#material-ui/core": "^4.12.4",
"#material-ui/icons": "^4.11.3",
"#material-ui/lab": "^4.0.0-alpha.61",
"#react-pdf/renderer": "^3.0.0",
"#splinetool/react-spline": "^2.2.1",
"#splinetool/runtime": "^0.9.104",
"#testing-library/jest-dom": "^5.16.5",
"#testing-library/react": "^13.3.0",
"#testing-library/user-event": "^13.5.0",
"axios": "^0.27.2",
"firebase": "^9.9.4",
"lodash": "^4.17.21",
"react": "^18.2.0",
"react-datepicker": "^4.8.0",
"react-dom": "^18.2.0",
"react-image-file-resizer": "^0.4.8",
"react-image-gallery": "^1.2.9",
"react-modal-image": "^2.5.0",
"react-query": "^3.39.2",
"react-responsive-carousel": "^3.2.23",
"react-router": "^6.3.0",
"react-router-dom": "^6.3.0",
"react-scripts": "5.0.1",
"react-toastify": "^9.0.8",
"styled-components": "^5.3.5",
"web-vitals": "^2.1.4"
},
"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"
]
}
}
Any help would be appreciated.
my versions are:-
node.js :- v16.16.0
please change your node version to latest and try once hop it works .it seems you are using outdated node version to your current project.
I'm trying to make a typescript frontend but I can't use the react-dom/client import because of an issue that I've narrowed down to my testing-library/react version not corresponding with my react version. I've tried multiple downgraded versions but can't seem to get it to work.
Is there any solutions to this? I'll attach my package.json file below.
{
"name": "balls",
"version": "0.1.0",
"private": true,
"dependencies": {
"#material-ui/core": "^4.12.4",
"#material-ui/icons": "^4.11.3",
"#testing-library/jest-dom": "^5.16.4",
"#testing-library/react": "12.1.5",
"#testing-library/user-event": "^13.5.0",
"#types/jest": "^27.5.1",
"#types/node": "^16.11.35",
"#types/react": "^16.8.6",
"#types/react-dom": "^16.8.6",
"#vercel/node": "^1.15.2",
"axios": "^0.27.2",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-scripts": "5.0.1",
"typescript": "^4.6.4",
"vercel": "^24.2.3",
"web-vitals": "^2.1.4"
},
"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"
]
}
}
Looking at the peer dependencies of package.json of the version 12 of react-testing-library we can say that until version 12.*, react-testing-library supports any react version before react 18. As of react-testing-library 13, it requires react 18.
So to answer the question, at the time of writing, you can use react-testing-library 12.1.5 with react 16.8.6.
Have been struggling with dependency issues to no avail. I have built a React app (with typescript). I first added Auth0 authentication which requires React version 16.14.0. This works well despite being a more dated version of React.
Then, I wanted to install Material UI, however this requires React >17.0.0. How can I handle these dependency conflicts?
package.json
{
"name": "23xi-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"#auth0/auth0-react": "^1.9.0",
"#testing-library/jest-dom": "^5.16.3",
"#testing-library/react": "^12.1.4",
"#testing-library/user-event": "^13.5.0",
"#types/jest": "^27.4.1",
"#types/node": "^16.11.26",
"#types/react": "^17.0.43",
"#types/react-dom": "^17.0.14",
"#types/styled-components": "^5.1.24",
"add": "^2.0.6",
"react": "^17.0.0",
"react-dom": "^16.14.0",
"react-icons": "^4.3.1",
"react-scripts": "5.0.0",
"styled-components": "^5.3.5",
"typescript": "^4.6.3",
"web-vitals": "^2.1.4"
},
"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"
]
}
}
I am trying to implement a sortable image list using some npm package.
I googled but I couldn't find any remarkable resource.
If I find some package like react-sortable-hoc ,react-sortable and some others then such packages doesn't full compliance with react 17 version.
If I use react-sortable-hoc then there are many errors while using "array-move" and related to array modification.
Can any one suggest some popular react 17 sortable package and an example?
Following is my package.json file.
{
"name": "test-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"#hookform/resolvers": "^2.7.0",
"#testing-library/jest-dom": "^5.12.0",
"#testing-library/react": "^11.2.7",
"#testing-library/user-event": "^12.8.3",
"bootstrap": "^4.6.0",
"faker": "^5.5.3",
"node-sass": "^4.14.1",
"react": "^17.0.2",
"react-bootstrap": "^1.6.1",
"react-bootstrap-sweetalert": "^5.2.0",
"react-data-table-component": "^6.11.7",
"react-dom": "^17.0.2",
"react-hook-form": "^7.12.2",
"react-icons": "^4.2.0",
"react-router-dom": "^5.2.0",
"react-scripts": "^4.0.3",
"react-sortable-hoc": "^2.0.0",
"styled-components": "^5.3.0",
"web-vitals": "^1.1.2",
"yup": "^0.32.9"
},
"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"
]
},
}
I want to make a sortable image list by drag and drop feature.
Thank you
in order to deploy react app on the tomcat server I added homepage in the react app package.json.but after that images disappears from the react page.for image storage i have new folder image folder in the public folder and saved all my images there..and using the path to fetch images '/images/image1.jpg'
here is package.json
{
"name": "reactapp",
"version": "0.1.0",
"private": true,
"homepage": "https://localhost:8080/bunge",
"dependencies": {
"#fortawesome/fontawesome-free": "^5.15.3",
"#testing-library/jest-dom": "^5.11.10",
"#testing-library/react": "^11.2.6",
"#testing-library/user-event": "^12.8.3",
"axios": "^0.21.1",
"bootstrap": "^4.6.0",
"bootstrap-icons": "^1.4.1",
"font-awesome": "^4.7.0",
"react": "^17.0.2",
"react-bootstrap": "^1.5.2",
"react-dom": "^17.0.2",
"react-redux": "^7.2.3",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.3",
"react-thunk": "^1.0.0",
"redux": "^4.0.5",
"redux-thunk": "^2.3.0",
"web-vitals": "^1.1.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"
]
}
}