如何从 Gatsby V3 安装所有包

How to install all packages from Gatsby V3

我目前在版本 4 上安装了 Gatsby,但我想将其“降级”到版本 3,并且所有依赖项都与版本 3 兼容。

是否有任何方法可以将所有内容“降级”到最新的 V3 版本?

我的package.json

"dependencies": {
    "@babel/plugin-transform-typescript": "^7.16.1",
    "@styled-icons/boxicons-regular": "^10.38.0",
    "@types/node": "^16.11.7",
    "@types/react": "^17.0.34",
    "@types/react-helmet": "^6.1.4",
    "gatsby": "^4.1.1",
    "gatsby-plugin-gatsby-cloud": "^4.1.0",
    "gatsby-plugin-image": "^2.1.2",
    "gatsby-plugin-manifest": "^4.1.0",
    "gatsby-plugin-offline": "^5.1.0",
    "gatsby-plugin-react-helmet": "^5.1.0",
    "gatsby-plugin-sharp": "^4.1.3",
    "gatsby-source-filesystem": "^4.1.2",
    "gatsby-transformer-sharp": "^4.1.0",
    "plop": "^2.7.6",
    "prop-types": "^15.7.2",
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "react-helmet": "^6.1.0",
    "react-icons": "^4.3.1",
    "react-markdown": "^7.1.0",
    "rehype-raw": "^6.1.0",
    "styled-components": "^5.3.3",
    "styled-media-query": "^2.1.2",
    "swiper": "^7.2.0",
    "tslint": "^6.1.3",
    "typescript": "^4.4.4"
  },
  "devDependencies": {
    "@babel/core": "^7.16.0",
    "@react-icons/all-files": "^4.1.0",
    "@storybook/addon-actions": "^6.3.12",
    "@storybook/addon-essentials": "^6.3.12",
    "@storybook/addon-links": "^6.3.12",
    "@storybook/builder-webpack5": "^6.3.12",
    "@storybook/manager-webpack5": "^6.3.12",
    "@storybook/react": "^6.3.12",
    "@types/react-dom": "^17.0.11",
    "@types/styled-components": "^5.1.15",
    "@types/swiper": "^5.4.3",
    "@typescript-eslint/eslint-plugin": "^5.3.1",
    "@typescript-eslint/parser": "^5.3.1",
    "babel-loader": "^8.2.3",
    "babel-plugin-styled-components": "^1.13.3",
    "chromatic": "^6.0.6",
    "eslint": "^8.2.0",
    "eslint-config-prettier": "^8.3.0",
    "eslint-plugin-prettier": "^4.0.0",
    "eslint-plugin-react": "^7.27.0",
    "eslint-plugin-react-hooks": "^4.3.0",
    "gatsby-plugin-scss-typescript": "^5.1.0",
    "gatsby-plugin-styled-components": "^5.1.0",
    "gatsby-plugin-typescript-scss-modules": "^1.0.7",
    "prettier": "^2.4.1",
    "storybook-addon-gatsby": "^0.0.2"
  },

没有神奇的命令可以自动降级 Gatsby 版本和所有相关依赖项。基本上,您需要卸载并重新安装 Gatsby 到您想要的版本:

如果您需要重置 gatsby-cli 版本:

npm uninstall -g gatsby-cli
npm install -g gatsby-cli@latest

之后:

npm install gatsby@3.14

其中 3.14 是您想要的版本(根据 releases notes 它应该是 3.14)。

然后,您需要运行:

npm outdated

修复你的依赖版本。

在安装和审核软件包之前,您需要删除 node_modulespackage-lock.json 以避免锁定依赖项和奇怪的行为。