如何解决带有Ant设计的Snowpack:无法解析导入的“ antd”
我想将Ant Design与Snowpack一起使用。我遵循And Design文档并安装了antd,但是无论何时运行我的应用程序,都无法解决依赖关系。
我收到以下错误消息:
[snowpack] Import "antd" could not be resolved.
If this is a new package,re-run Snowpack with the --reload flag to rebuild.
If Snowpack is having trouble detecting the import,add "install": ["antd"] to your Snowpack config file.
我的App.tsx:
import React from 'react';
import './App.css';
import { Button } from 'antd';
function App(): JSX.Element {
return (
<div className="App">
<Button type="primary">Button</Button>
</div>
);
}
export default App;
我的package.json依赖项:
"dependencies": {
"antd": "^4.6.2","axios": "^0.20.0","postcss": "^7.0.32","react": "^16.13.1","react-dom": "^16.13.1","react-hook-form": "^6.7.0","tailwindcss": "^1.7.6"
},"devDependencies": {
"@snowpack/app-scripts-react": "^1.10.0","@testing-library/jest-dom": "^5.5.0","@testing-library/react": "^10.0.3","@types/react": "^16.9.35","@types/react-dom": "^16.9.8","@types/snowpack-env": "^2.3.0","@typescript-eslint/eslint-plugin": "^4.0.1","@typescript-eslint/parser": "^4.0.1","eslint": "^7.8.0","eslint-config-prettier": "^6.11.0","eslint-plugin-prettier": "^3.1.4","eslint-plugin-react": "^7.20.6","eslint-plugin-react-hooks": "^4.1.0","jest": "^26.2.2","postcss-cli": "^7.1.2","prettier": "^2.0.5","snowpack": "^2.9.0","typescript": "^3.9.7"
}
我想念什么吗?
解决方法
确保已安装antd
。在snowpack.config.json
中尝试:
module.exports = {
mount: {
public: '/',src: '/_dist_',}
installOptions: {
namedExports: ['antd'],},};
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。