0

我最近开始使用 NVM,但这样做无意中破坏了我的 Gatsby 站点依赖项,特别是 Sharp 依赖项。我使用的是 Node 10.16.0,但我认为该错误是由使用 Node 12 运行安装引起的。

问题是我的一些模块没有被正确导入——特别是typography.js,但我认为问题出在Sharp包上。在清除缓存并重建之前,我在 Netlify 上遇到了构建问题,现在一切都在部署中。我认为问题是缓存在我的本地机器上。

所以我尝试了以下方法:

  • 删除 package-lock.json
  • 删除 node_modules 并运行 npm install 或 yarn install
  • 删除我的项目目录中的缓存和公用文件夹

到目前为止,这些都没有奏效。

这是 package.json:

"dependencies": {
        "@fortawesome/fontawesome-svg-core": "^1.2.19",
        "@fortawesome/free-brands-svg-icons": "^5.9.0",
        "@fortawesome/free-solid-svg-icons": "^5.9.0",
        "@fortawesome/react-fontawesome": "^0.1.4",
        "@glidejs/glide": "^3.3.0",
        "babel-plugin-styled-components": "^1.10.0",
        "bootstrap": "^4.3.1",
        "express": "^4.17.1",
        "gatsby": "^2.8.5",
        "gatsby-background-image": "^0.2.74",
        "gatsby-image": "^2.1.2",
        "gatsby-plugin-express": "^1.1.6",
        "gatsby-plugin-manifest": "^2.1.1",
        "gatsby-plugin-offline": "^2.1.1",
        "gatsby-plugin-react-helmet": "^3.0.12",
        "gatsby-plugin-sharp": "^2.1.3",
        "gatsby-plugin-styled-components": "^3.0.7",
        "gatsby-plugin-typography": "^2.2.13",
        "gatsby-remark-copy-linked-files": "^2.0.13",
        "gatsby-remark-images": "^3.0.14",
        "gatsby-remark-prismjs": "^3.2.10",
        "gatsby-source-contentful": "^2.0.67",
        "gatsby-source-filesystem": "^2.0.38",
        "gatsby-transformer-remark": "^2.3.12",
        "gatsby-transformer-sharp": "^2.1.21",
        "prismjs": "^1.16.0",
        "prop-types": "^15.7.2",
        "react": "^16.8.6",
        "react-bootstrap": "^1.0.0-beta.9",
        "react-dom": "^16.8.6",
        "react-glider": "^1.1.2",
        "react-helmet": "^5.2.1",
        "react-pure-lifecycle": "^3.0.0",
        "react-scroll": "^1.7.11",
        "react-typography": "^0.16.19",
        "sharp": "^0.22.1",
        "styled-components": "^4.2.1",
        "typography": "^0.16.19",
        "typography-theme-lawton": "^0.16.19"
    },
    "devDependencies": {
        "gatsby-plugin-remove-trailing-slashes": "^2.0.11",
        "nodemon": "^1.19.1",
        "prettier": "^1.17.1"
    },

如果有任何关于如何重置依赖项的建议会很棒......非常感谢。

4

0 回答 0