postcss-svgo:TypeError:无法设置未定义的属性“ multipassCount”(Gatsby)

Mar*_*ara 13 redhat node.js webpack postcss gatsby

在Gatsby 2.17.6项目中,构建时:

构建生产JavaScript和CSS包[====
] 1.940 s 1/6 17%运行查询失败构建生产JavaScript和CSS包-75.519s

错误#98123 WEBPACK

生成JavaScript包失败

postcss-svgo:TypeError:无法设置 未定义的属性“ multipassCount”

未完成运行查询-77.639s npm错误!代码ELIFECYCLE npm ERR!errno 1 npm错误!gatsby-starter-default@1.0.0 build:节点node_modules / gatsby / dist / bin / gatsby.js build` npm ERR!退出状态1

这些是我的一些依赖项:

"dependencies": {
    "babel-plugin-styled-components": "^1.8.0",
    :
    "gatsby": "^2.0.19",
    "gatsby-plugin-favicon": "^3.1.4",
    "gatsby-plugin-google-fonts": "0.0.4",
    "gatsby-plugin-offline": "^2.0.5",
    "gatsby-plugin-react-helmet": "^3.0.0",
    "gatsby-plugin-styled-components": "^3.0.1",
    :
    "react": "^16.5.1",
    "react-dom": "^16.5.1",
    "react-helmet": "^5.2.0",
    "react-leaflet": "^2.1.1",
    "styled-components": "^4.1.1"
  }
Run Code Online (Sandbox Code Playgroud)

我在gatsby-config.js上没有看到关于postcss的任何配置,我想这是Gatsby的默认行为。npm ls postcss-svgo抛出这个:

gatsby-starter-default@1.0.0 /<app>/source
??? gatsby@2.17.6
  ??? optimize-css-assets-webpack-plugin@5.0.3
    ??? cssnano@4.1.10
      ??? cssnano-preset-default@4.0.7
        ??? postcss-svgo@4.0.2 
Run Code Online (Sandbox Code Playgroud)

如果这是一种解决方案,我不介意禁用postcss-svgo,但是我不知道如何。

小智 8

我的项目已解决,使用npm install svgo@1.3.0 -E,详细信息请参见:https//github.com/svg/svgo/issues/1174


Sha*_*rav 5

"resolutions": { "svgo": "1.3.0" }

将以上内容添加到“ package.json”,然后rm -rf node_modules删除“ node_modules”,然后再次重新安装“ node_modules”。

这样可以解决问题。此问题与最新版本的postcss-svgo有关。


Mar*_*ara 0

svgo 1.3.2版本已经发布,这个bug预计会被修复

因此,删除你的node_modules目录和package-lock.json文件就足够了,然后进行新的npm安装yarn安装

不管怎样,感谢其他用户建议将 svgo 回滚到 1.3.0