找不到模块:无法解析“@emotion/react”

Yah*_*var 13 reactjs

我想安装neumorphism-react

但我收到了这个错误

找不到模块:无法解析“C:\Users\Asus\Desktop\react projects\visitor\node_modules@emotion\styled\base\dist”中的“@emotion/react”

这是依赖项 package.json

"@emotion/core": "^11.0.0",
"@emotion/styled": "^11.0.0",
"@testing-library/jest-dom": "^5.11.6",
"@testing-library/react": "^11.2.2",
"@testing-library/user-event": "^12.6.0",
"neumorphism-react": "^1.1.1",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-scripts": "4.0.1",
"semantic-ui-react": "^2.0.1",
"web-vitals": "^0.2.4"
Run Code Online (Sandbox Code Playgroud)

小智 136

我遇到了类似的问题,我通过拨打以下电话解决了它:

npm install @emotion/react 
npm install @emotion/styled
Run Code Online (Sandbox Code Playgroud)

或者

 yarn add @emotion/react
 yarn add @emotion/styled
Run Code Online (Sandbox Code Playgroud)


nra*_*aus 20

我有一个类似的问题,我通过调用解决了它:

npm install @emotion/react
Run Code Online (Sandbox Code Playgroud)

或者

yarn add @emotion/react
Run Code Online (Sandbox Code Playgroud)

  • 出现此错误后,我得到 Can´t resolve @emotion/styled (9认同)
  • 安装软件包后,可能需要重新启动 npm。只需停止服务器并运行“npm start”即可。 (8认同)

小智 18

我遇到了类似的问题,我通过拨打以下电话解决了它:

对于 npm:

npm install @emotion/react 
npm install @emotion/styled
Run Code Online (Sandbox Code Playgroud)

对于纱线:

yarn add @emotion/react
yarn add @emotion/styled
Run Code Online (Sandbox Code Playgroud)

对于特定版本,您可以安装如下:@emotion/core@10.1.1 &@emotion/styled

在 npm 中:

npm install @emotion/core@10.1.1
npm install @emotion/styled
Run Code Online (Sandbox Code Playgroud)

在纱线中:

yarn add @emotion/core@10.1.1
yarn add @emotion/styled
Run Code Online (Sandbox Code Playgroud)


小智 17

一站式解决方案...

npm install @mui/material @emotion/react @emotion/styled
Run Code Online (Sandbox Code Playgroud)


Fus*_*ers 16

对于使用 nextJS 的用户,请尝试在安装依赖项后删除 .next 目录。

  • 我的上帝!你救了我。 (2认同)

Sky*_*Sky 8

您需要安装:@emotion/react 和 @emotion/styled,同时安装@mui/material, 有时看起来已经完成但仍然没有进展,在这些情况下只需 w8,它将完成取决于您的连接速度

npm install @mui/material @emotion/react @emotion/styled
Run Code Online (Sandbox Code Playgroud)

或者

npm install @mui/material 
npm install @emotion/react 
npm install @emotion/styled
Run Code Online (Sandbox Code Playgroud)

访问此安装文档安装 MUI


ABD*_*ALI 5

如果你使用 npm:

npm install  @emotion/react
Run Code Online (Sandbox Code Playgroud)

如果你使用纱线:

yarn add @emotion/react
Run Code Online (Sandbox Code Playgroud)

但是在最近的版本中,如果您使用其他依赖于 @emotion/core 的包,他们将包@emotion/core 重命名为@emotion/react

  • 这意味着您需要连接到源代码并将导入语句更新到新的 @emotion/react

或使用 npm 将包降级到旧版本

npm install @emotion/core@10.1.1
Run Code Online (Sandbox Code Playgroud)

带毛线

yarn add @emotion/core@10.1.1
Run Code Online (Sandbox Code Playgroud)


rou*_*cle 5

这些解决方案都不适合我。我通过运行解决了这个问题:

npm install @emotion/server
Run Code Online (Sandbox Code Playgroud)

我将 mui 与 nextjs 一起使用。


Sha*_*hah 2

package.json 目录中的“yarn install”或“node install”。

我正在查看文档,您尝试使用的包可能不存在。

确保您是从当前库导入。例如:

import { NeuButton } from "neumorphism-react";
Run Code Online (Sandbox Code Playgroud)