npm 如何修复react-gauge-chart上的 Package 依赖

li9yvcax  于 11个月前  发布在  React
关注(0)|答案(2)|浏览(144)

我试图找到一个名为react-gauge-chart的软件包导致的打包问题。在安装后,显示错误'模块未找到'。我想知道这个问题背后的原因。
这个问题发生在我的本地以及在codesandbox example
以下是我的本地错误:

Failed to compile.

./src/views/home/CorrectiveMaintainanceReport.jsx
Module not found: Can't resolve 'react-gauge-chart' in '/Users/kongwenyao/Documents/GitLab/wefix/src/views/home'

字符串
下面是Codesandbox的错误:

Error

Could not fetch dependencies, please try again in a couple seconds: Something went wrong while packaging the dependency [email protected]: ENOENT: no such file or directory, scandir '/tmp/3739059402/node_modules/react-gauge-chart/dist'


我在package.json中的本地依赖

"dependencies": {
        "axios": "^0.18.0",
        "chart.js": "2.7.3",
        "classnames": "2.2.6",
        "eslint-config-google": "^0.12.0",
        "moment": "2.24.0",
        "node-sass": "4.11.0",
        "nouislider": "13.1.1",
        "react": "16.8.4",
        "react-chartjs-2": "2.7.4",
        "react-copy-to-clipboard": "5.0.1",
        "react-datetime": "2.16.3",
        "react-dom": "16.8.4",
        "react-gauge-chart": "^0.1.2",
        "react-google-maps": "9.4.5",
        "react-router-dom": "4.3.1",
        "react-scripts": "2.1.8",
        "reactstrap": "7.1.0"
    },

wgmfuz8q

wgmfuz8q1#

因为你的包模块没有所需的包
安装

yarn add react-gauge-chart or npm install react-gauge-chart

字符串
还要确保它在package.json中的dependency下列出

6vl6ewon

6vl6ewon2#

看起来您缺少类型化库,请尝试运行npm i --save-dev @types/react-gauge-chart

相关问题