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

IT技术 reactjs
2021-05-14 05:14:24

我想安装neumorphism-react包。

但我收到了这个错误

找不到module:无法解析“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"
4个回答

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

npm install @emotion/react

或者

yarn add @emotion/react

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

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

或者

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

如果你使用 npm:

npm install  @emotion/react

如果你使用纱线:

yarn add @emotion/react

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

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

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

npm install @emotion/core@10.1.1

带毛线

yarn add @emotion/core@10.1.1

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

对于 npm:

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

对于纱线:

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

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

在 npm 中:

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

在纱线中:

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