如何修复 "Module not found: Can't resolve 'react'"?

How to fix "Module not found: Can't resolve 'react'"?

我正在尝试让 particlesjs 响应 运行。但这似乎不起作用..所以,我尝试使用 react-particles-js 。但它给了我这个错误: 找不到模块:无法解析 'C:\Users\Amit\node_modules\particles-js\lib'

中的 'react'
        import React, { Component } from 'react';

        import ParticleAnimation from 'particles-js';

         class Example extends Component {
            render () {
               return (
              <ParticleAnimation />
          )
        }
       }export default Example;

我一直在尝试修改导入语句中的文件路径,但到目前为止没有任何效果。

尝试在您的项目中再次安装它,

yarn add react

npm i react --save