【问题标题】:how do I run material-ui locally如何在本地运行 material-ui
【发布时间】:2018-11-16 19:15:36
【问题描述】:

我正在尝试在本地运行 material-ui 文档。我下载了material-ui仓库

https://github.com/mui-org/material-ui/

npm 安装了吗

现在当我尝试运行它时,我收到以下错误

ERROR 编译失败,出现 5 个错误 11:06:22

未找到这些依赖项:

  • ./packages/material-ui/src/styles/withStyles.js 中的 react-jss/lib/contextTypes
  • ./packages/material-ui/src/styles/withStyles.js 中的 react-jss/lib/ns
  • 在 ./packages/material-ui/src/styles/withStyles.js 中重构/getDisplayName
  • 在 ./packages/material-ui/src/styles/withTheme.js、./packages/material-ui/src/styles/withStyles.js 中重构/wrapDisplayName

要安装它们,您可以运行: npm install --save react-jss/lib/contextTypes react-jss/lib/ns recompose/getDisplayName recompose/wrapDisplayName

正如我现在尝试运行时出现的错误状态 npm install --save react-jss/lib/contextTypes react-jss/lib/ns recompose/getDisplayName recompose/wrapDisplayName

我收到以下错误

  • 要求我访问我无权访问的存储库
  • npm 错误!无法从“react-jss\lib\contextTypes”安装,因为它不包含 package.json 文件。

如何让它在本地运行?

【问题讨论】:

    标签: material-ui


    【解决方案1】:

    Material UI 文档是相当庞大的文档,不推荐在开发模式下启动。最好有一个生产版本并将其本地托管在您的 PC 上。

    首先,克隆存储库。

    git clone https://github.com/mui-org/material-ui.git
    cd material-ui
    

    使用 yarn 安装依赖项。

    yarn
    

    然后创建文档的优化生产版本。

    yarn docs:build
    

    然后在生产环境下部署构建。

    yarn docs:start
    

    您可以通过转到package.json 文件并查看scripts 对象来找到更多有用的命令。

    【讨论】:

      【解决方案2】:

      Material UI 使用yarn workspaces 来管理多个包之间的依赖关系。要一次安装所有依赖项,您需要使用 yarn 而不是 npm。

      如果您使用npm,您需要为packages/ 目录中的每个包运行npm install

      更多信息请参考 Material-UI 的contributing guidelines

      要求

      在本地运行文档

      1. 将存储库克隆到您的本地计算机。

      $ git clone https://github.com/mui-org/material-ui.git
      $ cd material-ui
      

      2.安装依赖项

      $ yarn
      

      3.启动开发服务器

      $ yarn docs:dev
      

      这会以开发模式启动文档站点。对代码进行更改将热重新加载站点。

      如果您对文档中的 TypeScript 文件进行更改,请在单独的终端中运行 yarn docs:typescript --watch

      【讨论】:

      • 我尝试了这个,仍然得到同样的错误错误无法编译,出现 5 个错误 15:22:55 找不到这些依赖项:* react-jss/lib/contextTypes in ./packages/material- ui/src/styles/withStyles.js * ./packages/material-ui/src/styles/withStyles.js 中的 react-jss/lib/ns * ./packages/material-ui/src/styles/ 中的 recompose/getDisplayName withStyles.js * 在 ./packages/material-ui/src/styles/withStyles.js, ./packages/material-ui/src/styles/withTheme.js 中重构/wrapDisplayName
      • 您是否尝试删除 node_modules 目录,然后使用 yarn 安装?
      • 当我使用npm install. 安装时,我遇到了与您相同的错误删除 node_modules 目录,然后使用yarn 重新安装应该可以解决它。让我知道这是否适合您。
      • 嗯...安装了哪些版本的node/npm/yarn?
      • 我升级了 yarn 版本,它工作正常。我有点困惑这可能是如何导致问题的,以及为什么如果我使用 npm 而不是 yarn 它将无法工作。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-01-06
      • 2017-06-13
      • 2021-06-06
      • 2018-09-25
      • 1970-01-01
      • 1970-01-01
      • 2021-03-22
      相关资源
      最近更新 更多