I am unable to use react particles in my project. Following the documentation, i installed react-particles, and when it did not work, i installed react-tsparticles but still it gives me same error: Module not found: Can't resolve 'tsparticles' Please Help me in this. Below is my dependency file.
{
"name": "portfolio-react",
"version": "0.1.0",
"private": true,
"dependencies": {
"@fortawesome/free-solid-svg-icons": "^5.15.3",
"@testing-library/jest-dom": "^5.14.1",
"@testing-library/react": "^11.2.7",
"@testing-library/user-event": "^12.8.3",
"bootstrap": "^5.0.2",
"react": "^17.0.2",
"react-bootstrap": "^1.6.1",
"react-dom": "^17.0.2",
"react-particles-js": "^3.5.3",
"react-scripts": "4.0.3",
"react-tsparticles": "^1.30.4",
"react-typed": "^1.2.0",
"web-vitals": "^1.1.2"
},
"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"
]
},
"devDependencies": {
"tslint": "^5.0.0"
}
}
When you install the npm i react-particles-js in your project. In the initial doc the develper mentioned the react-particles-js is dependant on "tsparticles" so you just install "npm i tsparticles".
npm i tsparticles
Nothing else and restart your server .I think this time its working fine. Here is my Particle component.
import React from 'react'
import Particles from 'react-particles-js'
function Particless (){
return (
<Particles
params={{
particles: {
number: {
value: 200,
density: {
enable: true,
value_area: 1000,
}
},
},
}}
/>
)
}
export default Particless
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>
try installing ts particles npm package as this should fix the issue
Uninstall "react-particles-js", because it's deprecated. Install "react-particles" instead.
npm install react-particles
In your Component:
import Particles from "react-particles";
here is what I did.
removed the node modules > removed the packagelock.json > npm i tsparticles
then it worked for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With