简体   繁体   English

找不到模块:错误:无法使用 typescript 解析“react-select”

[英]Module not found: Error: Can't resolve 'react-select' with typescript

module import is not working for me.模块导入对我不起作用。 I'm tried different solutions provided from stack overflow and other.我尝试了堆栈溢出和其他提供的不同解决方案。 These are steps I'm follow the react-select这些是我遵循反应选择的步骤

npm install --save @types/react-select

import the module like this像这样导入模块

import Select from "react-select"

but I got the error但我得到了错误

Module not found: Error: Can't resolve 'react-select'找不到模块:错误:无法解析“反应选择”

import * as React from "react";
import ReactSelect from 'react-select'
export class Select extends extends React.Component<someProps>{

render(){
   return(
  <Select id="color" options={options} />
);
}
}

But I can't find the way to fixed this.但我找不到解决这个问题的方法。

我通过npm i react-select得到了解决方案。

You have an error:你有一个错误:

npm install --save @type/react-select

instead of代替

npm install --save @types/react-select

Also I would recommend to use --save-dev instead of --save because you don't need typings in production.此外,我建议使用--save-dev而不是--save因为您不需要在生产中进行输入。

I found the issue having here.我发现这里有问题。 Issue is both @types/react-select and react-select added to the package.json问题是@types/react-selectreact-select添加到package.json

My error was a bit different since it involves react-select-async-paginate.我的错误有点不同,因为它涉及 react-select-async-paginate。

So in my case, I had to use,所以就我而言,我不得不使用,

npm install react-select react-select-async-paginate

or或者

yarn add react-select react-select-async-paginate

Hope this helps someone:)希望这对某人有帮助:)

暂无
暂无

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

相关问题 更新 React-Select 后:找不到模块:无法解析 'react-select/dist/react-select.css - After updating React-Select: Module not found: Can't resolve 'react-select/dist/react-select.css 找不到模块:错误:无法解析“反应” - Module not found: Error: Can't resolve 'react' 找不到模块:错误:无法从带有 TypeScript 的 React 18 解析“./App” - Module not found: Error: Can't resolve './App' from React 18 w/TypeScript TypeScript React 错误:“找不到模块:无法解析 'styled-components'” - TypeScript React error: “Module not found: Can't resolve 'styled-components'” 找不到模块:错误:无法解析 typescript 中的“openlayers” - Module not found: Error: Can't resolve 'openlayers' in typescript 使用 CRACO、React 和 typescript 的模块联合会抛出错误:找不到模块无法解析模块“mfe1/Component” - Module federation using CRACO, React and typescript throws error: Module not found Can't resolve module "mfe1/Component" 反应:找不到模块:错误:无法解析“反应/库/更新” - React: Module not found: Error: Can't resolve 'react/lib/update' Typescript 找不到模块 无法解决 - Typescript Module not found Can't resolve 反应:“未找到模块:无法解析”路径错误 - React: "Module not found: Can't resolve" Path error 找不到模块:错误:无法解析“react-bootstrap-validation” - Module not found: Error: Can't resolve 'react-bootstrap-validation'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM