当我在gatsby-confis.js文件中添加gatsby-plugin-sass时

时间:2019-07-18 08:15:01

标签: reactjs gatsby

plugins: [
    `gatsby-plugin-react-helmet`,
    `gatsby-plugin-sass`,
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        name: `images`,
        path: `${__dirname}/src/images`,
      },
    },
    `gatsby-transformer-sharp`,
    `gatsby-plugin-sharp`,
    {
      resolve: `gatsby-plugin-manifest`,
      options: {
        name: `gatsby-starter-default`,
        short_name: `starter`,
        start_url: `/`,
        background_color: `#663399`,
        theme_color: `#663399`,
        display: `minimal-ui`,
        icon: `src/images/gatsby-icon.png`, // This path is relative to the root of the site.
      },
    },
    // this (optional) plugin enables Progressive Web App + Offline functionality
    // To learn more, visit: https://gatsby.dev/offline
    // `gatsby-plugin-offline`,
  ],

已经添加了插件,但仍然出错

  

模块构建失败(来自./node_modules/sass-loader/lib/loader.js):
  错误:找不到模块“ node-sass”

1 个答案:

答案 0 :(得分:1)

Nose Sass不包含在插件中,因此也请尝试运行:

npm install -S node-sass

每位:https://www.gatsbyjs.org/packages/gatsby-plugin-sass/#install

这样,对于大多数更改,您可以轻松升级或更改Node Sass的版本,而无需等待Gatsby插件维护人员的更改。

希望有帮助!