Module not found: Error: Can't resolve 'react-select' with typescript
Module not found: Error: Can't resolve 'react-select' with typescript
模块导入对我不起作用。我尝试了堆栈溢出和其他提供的不同解决方案。
这些是我遵循 react-select
的步骤
npm install --save @types/react-select
像这样导入模块
import Select from "react-select"
但我得到了错误
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} />
);
}
}
但是我找不到解决这个问题的方法。
你有一个错误:
npm install --save @type/react-select
而不是
npm install --save @types/react-select
另外我建议使用 --save-dev
而不是 --save
因为你不需要在生产中打字。
我发现这里有问题。问题是 @types/react-select
和 react-select
添加到 package.json
我通过 npm i react-select
找到了解决方案。
模块导入对我不起作用。我尝试了堆栈溢出和其他提供的不同解决方案。 这些是我遵循 react-select
的步骤npm install --save @types/react-select
像这样导入模块
import Select from "react-select"
但我得到了错误
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} />
);
}
}
但是我找不到解决这个问题的方法。
你有一个错误:
npm install --save @type/react-select
而不是
npm install --save @types/react-select
另外我建议使用 --save-dev
而不是 --save
因为你不需要在生产中打字。
我发现这里有问题。问题是 @types/react-select
和 react-select
添加到 package.json
我通过 npm i react-select
找到了解决方案。