[英]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-select
和react-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.