我试图将particles.js npm添加到我的项目中,但是,当我将脚本添加到App.js并保存时,我得到了下面的错误消息:
./node_modules/react-particles-js/cjs/particles.js 53:14-62中的错误
未找到模块:错误:包路径。/Plugins/PolygonMask/Enum未从Package C:\Users\mekstein\Desktop\facerecognition\node_modules\tsparticles导出(请参阅C:\Users\mekstein\Desktop\facerecognition\node_modules\tsparticles\package.json)中的导出字段)
./node_modules/react-particles-js/cjs/particles.js 482中的错误:14-42
模块未找到:错误:包路径./Enum未从包C:\Users\mekstein\Desktop\facerecognition\node_modules\tsparticles导出(请参阅C:\Users\mekstein\Desktop\facerecognition\node_modules\tsparticles\package.json)中的导出字段)
./node_modules/react-particles-js/cjs/particles.js 484中的错误:14-60
未找到模块:错误:包路径./Plugins/吸收器/Enum未从Package C:\Users\mekstein\Desktop\facerecognition\node_modules\tsparticles导出(请参阅C:\Users\mekstein\Desktop\facerecognition\node_modules\tsparticles\package.json)中的导出字段)
./node_modules/react-particles-js/cjs/particles.js 486中的错误:14-59
未找到模块:错误:包路径./Plugins/Emitters/Enums未从Package C:\Users\mekstein\Desktop\facerecognition\node_modules\tsparticles导出(请参阅C:\Users\mekstein\Desktop\facerecognition\node_modules\tsparticles\package.json)中的导出字段)
这是我的js
import React, {Component} from 'react';
import Particles from 'react-particles-js';
import Navigation from './components/Navigation/Navigation';
import Logo from './components/Logo/Logo';
import ImageLinkForm from './components/ImageLinkForm/ImageLinkForm';
import Rank from './components/Rank/Rank';
import './App.css';
const particlesOptions = {
particles: {
line_linked: {
shadow: {
enable: true,
color: "#3CA9D1",
blur: 5
}
}
}
}
class App extends Component {
render() {
return (
<div className="App">
<Particles
params={particlesOptions}
/>
<Navigation />
<Logo />
<Rank />
<ImageLinkForm />
{/*<FaceRecognition />*/}
</div>
);
}
}
export default App;发布于 2022-08-24 14:29:39
在react-particles-js上有一个反对通知:https://github.com/wufe/react-particles-js#warning-deprecation-notice
转而迁移到react-particles (这只是在弃用通知中指定的react-tsparticles的新命名):https://github.com/matteobruni/tsparticles/tree/main/components/react
https://stackoverflow.com/questions/73408405
复制相似问题