简体   繁体   English

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

[英]Module not found: Can't resolve '@emotion/react'

I want to install neumorphism-react package.我想安装neumorphism-react package。

But I got this error但我得到了这个错误

Module not found: Can't resolve '@emotion/react' in 'C:\Users\Asus\Desktop\react projects\visitor\node_modules@emotion\styled\base\dist'未找到模块:无法在“C:\Users\Asus\Desktop\react projects\visitor\node_modules@emotion\styled\base\dist”中解析“@emotion/react”

Here are the dependencies in package.json以下是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"

I had a similar issue and I resolved it by calling:我有一个类似的问题,我通过调用解决了它:

npm install @emotion/react 
npm install @emotion/styled

or或者

 yarn add @emotion/react
 yarn add @emotion/styled

I had a similar issue and I resolved it by calling:我有一个类似的问题,我通过调用解决了它:

npm install @emotion/react

or或者

yarn add @emotion/react

if you use npm:如果您使用 npm:

npm install  @emotion/react

if you use yarn:如果你使用纱线:

yarn add @emotion/react

but in recent version they rename the package @emotion/core to @emotion/react, if you use other package that are depending on @emotion/core但在最近的版本中,他们将 package @emotion/core 重命名为 @emotion/react,如果您使用其他依赖于 @emotion/core 的 package

  • that mean you need to hook up to source code and update import statement to the new @emotion/react这意味着您需要连接到源代码并将导入语句更新为新的@emotion/react

or downgrade package to older versions with npm或使用 npm 将 package 降级到旧版本

npm install @emotion/core@10.1.1

with yarn用纱

yarn add @emotion/core@10.1.1

I had a similar issue and I resolved it by calling:我有一个类似的问题,我通过调用解决了它:

for the npm:对于 npm:

npm install @emotion/react 
npm install @emotion/styled

for the yarn:对于纱线:

yarn add @emotion/react
yarn add @emotion/styled

For specific version you can install like: @emotion/core@10.1.1 & @emotion/styled对于特定版本,您可以像这样安装: @emotion/core@10.1.1 & @emotion/styled

in npm:在 npm 中:

npm install @emotion/core@10.1.1
npm install @emotion/styled

in yarn:在纱线中:

yarn add @emotion/core@10.1.1
yarn add @emotion/styled

'yarn install' or 'node install' at the directory of package.json. package.json目录下的“yarn install”或“node install”。

I'm looking at the docs, the package you're trying to use may not exist.我正在查看文档,您尝试使用的 package 可能不存在。

Make sure you are importing from the current library.确保您从当前库中导入。 For example:例如:

import { NeuButton } from "neumorphism-react";

Well, my issue was solved using npm install @emotion/styled or use yarn add @emotion/styled好吧,使用npm install @emotion/styled或使用yarn add @emotion/styled解决了我的问题

Only this worked for me:只有这对我有用:

npm i @emotion/styled @emotion/core

An all-stop solution...一站式解决方案...

npm install @mui/material @emotion/react @emotion/styled

Follow this link to install correctly.按照链接正确安装。

None of these solutions worked for me.这些解决方案都不适合我。 I resolved it by running:我通过运行解决了它:

npm install @emotion/server

I am using mui with nextjs.我正在将 mui 与 nextjs 一起使用。

Add below commands into package.json under Dependencies将以下命令添加到 Dependencies 下的 package.json

"@emotion/core": "^11.0.0",
"@emotion/react": "^11.8.2",
"@emotion/styled": "^11.8.1",

Run npm install运行 npm 安装

I had all of the above and still was getting the error.我拥有以上所有内容,但仍然出现错误。 I ended up deleting the yarn.lock & node_modules and the run yarn again我最终删除了 yarn.lock 和 node_modules 并再次运行yarn

I had the same issue.我遇到过同样的问题。 I tried npm install @emotion/react but it didn't solve my problem because I already had the package installed.我试过npm install @emotion/react但它没有解决我的问题,因为我已经安装了 package。

I restarted VS Code and the linter was happy我重新启动了 VS Code,linter 很高兴

I had the same error and resolved it by running the below commands.我有同样的错误并通过运行以下命令解决了它。

npm install @emotion/react npm install @emotion/core npm install @emotion/styled npm install @emotion/react npm install @emotion/core npm install @emotion/styled

These commands will install the emotion package to the dependencies of your project.这些命令会将情感 package 安装到项目的依赖项中。

after this, make sure you restart your development server and your IDE if necessary.在此之后,确保重启开发服务器和 IDE(如有必要)。 Your dev server won't pick up the changes until you stop it and re-run the npm start command.在您停止并重新运行 npm 启动命令之前,您的开发服务器不会获取更改。

also install the @emotion/css package if you are using css as well.如果您也使用 css,还请安装 @emotion/css package。

If the error still there then, try to delete your node_modules and package-lock.json file ( not package.json ) files, re-run npm install and restart your IDE. If the error still there then, try to delete your node_modules and package-lock.json file ( not package.json ) files, re-run npm install and restart your IDE.

visit for more information: https://bobbyhadz.com/blog/react-module-not-found-cant-resolve-emotion-react访问以获取更多信息: https://bobbyhadz.com/blog/react-module-not-found-cant-resolve-emotion-react

I had a similar issue and I resolved it by calling:我有一个类似的问题,我通过调用解决了它:

npm install @emotion/react

or或者

yarn add @emotion/react

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM