英文:
build failed using react-datepicker
问题
这是我的代码,这是一个TypeScript项目。
import React, { useState } from "react";
import ReactDatePicker from "react-datepicker";
export const DatePicker = () => {
const [startDate, setStartDate] = useState<Date | null>(new Date());
return (
<ReactDatePicker
selected={startDate}
onChange={(date) => setStartDate(date)}
/>
);
};
在运行构建时遇到以下错误:
ERROR in ../../node_modules/react-popper/lib/esm/index.js 2:0-34
Module not found: Error: Can't resolve './Popper' in '/Users/xx/pr/node_modules/react-popper/lib/esm'
ERROR in ../../node_modules/react-popper/lib/esm/index.js 3:0-36
Module not found: Error: Can't resolve './Manager' in '/Users/xx/pr/node_modules/react-popper/lib/esm'
ERROR in ../../node_modules/react-popper/lib/esm/index.js 4:0-40
Module not found: Error: Can't resolve './Reference' in '/Users/xx/pr/node_modules/react-popper/lib/esm'
...
react-popper
的版本是 2.3.0。我跳转到 react-popper/lib/esm/index.js
并找到了以下错误:
无法找到模块 './Popper' 的声明文件。
无法找到模块 './Manager' 的声明文件。
无法找到模块 './Reference' 的声明文件。
无法找到模块 './usePopper' 的声明文件。
有人可以帮助解决吗?
英文:
here is my code, it is a typescript procjet.
import React, { useState } from "react";
import ReactDatePicker from "react-datepicker";
export const DatePicker = () => {
const [startDate, setStartDate] = useState<Date | null>(new Date());
return (
<ReactDatePicker
selected={startDate}
onChange={(date) => setStartDate(date)}
/>
);
};
get the error when run build
ERROR in ../../node_modules/react-popper/lib/esm/index.js 2:0-34
Module not found: Error: Can't resolve './Popper' in '/Users/xx/pr/node_modules/react-popper/lib/esm'
ERROR in ../../node_modules/react-popper/lib/esm/index.js 3:0-36
Module not found: Error: Can't resolve './Manager' in '/Users/xx/pr/node_modules/react-popper/lib/esm'
ERROR in ../../node_modules/react-popper/lib/esm/index.js 4:0-40
Module not found: Error: Can't resolve './Reference' in '/Users/xx/pr/node_modules/react-popper/lib/esm'
...
the react-popper is 2.3.0.
I jump to the react-popper/lib/esm/index.js and find the error,
Could not find a declaration file for module './Popper'.
Could not find a declaration file for module './Manager'.
Could not find a declaration file for module './Reference'.
Could not find a declaration file for module './usePopper'.
can anyone help on it
答案1
得分: 0
尝试清理您的 node_modules 并运行 npm run install
;
进行干净安装的参考:如何使用 npm 进行干净安装(删除 node_modules 并安装)。
英文:
Try to clean your node_modules and run a npm run install
;
References for a clean install: How do I do a clean install (delete node_modules and install) with npm
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论