gatsbyjs / gatsby

The best React-based framework with performance, scalability and security built in.
https://www.gatsbyjs.com
MIT License
55.16k stars 10.33k forks source link

[v2] WebpackOptionsValidationError on upgrade attempt #6353

Closed lightstrike closed 5 years ago

lightstrike commented 6 years ago

Trying to upgrade a v1 project to v2, believe I followed all the relevant directions here. I had one onCreateWebpackConfig customization for using postscribe, but when I removed it the issue persisted the same. Here's the error I'm hitting:

error Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration.module.rules[6].oneOf[0].use should be one of these:
   non-empty string | function | object { loader?, options?, ident?, query? } | function | [non-empty string | function | object { loader?, options?, ident?, query? }]
   -> Modifiers applied to the module when rule is matched
   Details:
    * configuration.module.rules[6].oneOf[0].use should be a string.
    * configuration.module.rules[6].oneOf[0].use should be an instance of function
    * configuration.module.rules[6].oneOf[0].use should be an object.
    * configuration.module.rules[6].oneOf[0].use should be an instance of function
    * configuration.module.rules[6].oneOf[0].use[0] should be a string.
    * configuration.module.rules[6].oneOf[0].use[0] should be an instance of function
    * configuration.module.rules[6].oneOf[0].use[0] should be an object.

  WebpackOptionsValidationError: Invalid configuration object. Webpack has been   initialised using a configuration object that does not match the API schema.
   - configuration.module.rules[6].oneOf[0].use should be one of these:
     non-empty string | function | object { loader?, options?, ident?, query? }   | function | [non-empty string | function | object { loader?, options?, ident?  , query? }]
     -> Modifiers applied to the module when rule is matched
     Details:
      * configuration.module.rules[6].oneOf[0].use should be a string.
      * configuration.module.rules[6].oneOf[0].use should be an instance of func  tion
      * configuration.module.rules[6].oneOf[0].use should be an object.
      * configuration.module.rules[6].oneOf[0].use should be an instance of func  tion
      * configuration.module.rules[6].oneOf[0].use[0] should be a string.
      * configuration.module.rules[6].oneOf[0].use[0] should be an instance of f  unction
      * configuration.module.rules[6].oneOf[0].use[0] should be an object.

  - webpack.js:24 webpack
    [gatsby]/[webpack]/lib/webpack.js:24:9

  - develop-html.js:29 Promise
    [gatsby]/[gatsby]/dist/commands/develop-html.js:29:7

  - debuggability.js:303 Promise._execute
    [gatsby]/[bluebird]/js/release/debuggability.js:303:9

  - promise.js:483 Promise._resolveFromExecutor
    [gatsby]/[bluebird]/js/release/promise.js:483:18

  - promise.js:79 new Promise
    [gatsby]/[bluebird]/js/release/promise.js:79:10

  - develop-html.js:28 
    [gatsby]/[gatsby]/dist/commands/develop-html.js:28:12

  - Generator.next

  - next_tick.js:131 _combinedTickCallback
    internal/process/next_tick.js:131:7

  - next_tick.js:180 process._tickCallback
    internal/process/next_tick.js:180:9

package.json


  "name": "my-app",
  "description": "My App on Gatsby",
  "version": "0.1.0",
  "author": "Geoffrey Sechter <geoffrey@owlmountain.co>",
  "dependencies": {
    "gatsby": "next",
    "gatsby-image": "next",
    "gatsby-paginate": "^1.0.16",
    "gatsby-plugin-canonical-urls": "next",
    "gatsby-plugin-catch-links": "next",
    "gatsby-plugin-feed": "next",
    "gatsby-plugin-google-tagmanager": "next",
    "gatsby-plugin-manifest": "next",
    "gatsby-plugin-netlify": "next",
    "gatsby-plugin-react-helmet": "next",
    "gatsby-plugin-react-next": "next",
    "gatsby-plugin-sass": "next",
    "gatsby-plugin-sharp": "next",
    "gatsby-plugin-sitemap": "next",
    "gatsby-source-filesystem": "next",
    "gatsby-source-wordpress": "next",
    "gatsby-transformer-sharp": "next",
    "postscribe": "^2.0.8",
    "react": "^16.4.1",
    "react-dom": "^16.4.1",
    "react-helmet": "^5.2.0",
    "react-icons": "^2.2.7",
    "react-share": "^2.2.0",
    "react-super-responsive-table": "^4.2.4",
    "rehype": "^5.0.1",
    "sharp": "^0.20.4",
    "slugify": "^1.3.0",
    "universal-cookie": "^2.2.0"
  },
  "keywords": [
    "gatsby"
  ],
  "license": "MIT",
  "main": "n/a",
  "scripts": {
    "build": "node --max_old_space_size=1200000 --stack-size=65000 ./node_modules/.bin/gatsby build --prefix-paths",
    "develop": "gatsby develop",
    "format": "prettier --trailing-comma es5 --no-semi --single-quote --write \"src/**/*.js\"",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "devDependencies": {
    "prettier": "^1.13.5"
  }
}

gatsby-config:

let activeEnv = process.env.ACTIVE_ENV;

if (!activeEnv) {
  activeEnv = "development";
}

require("dotenv").config({
  path: `.env.${activeEnv}`
});

module.exports = {
  siteMetadata: {
    apiUrl: process.env.API_URL,
    apiPreviewUrl: process.env.API_PREVIEW_URL,
    faviconUrl: process.env.FAVICON_URL,
    justCommentsApiKey: process.env.JUST_COMMENTS_API_KEY,
    siteName: process.env.SITE_NAME,
    title: process.env.SITE_TITLE,
    description: process.env.SITE_DESCRIPTION,
    // gatsby-plugin-sitemap uses siteUrl
    siteUrl: process.env.SITE_URL
  },
  plugins: [
    {
      resolve: `gatsby-plugin-react-helmet`
    },
    {
      resolve: `gatsby-transformer-sharp`
    },
    {
      resolve: `gatsby-plugin-sharp`
    },
    {
      resolve: `gatsby-plugin-sass`
    },
    {
      resolve: `gatsby-source-wordpress`,
      options: {
        /*
        * The base URL of the Wordpress site without the trailing slash and the protocol. This is required.
        * Example : 'gatsbyjswpexample.wordpress.com' or 'www.example-site.com'
        */
        baseUrl: process.env.API_URL,
        // The protocol. This can be http or https.
        protocol: process.env.API_PROTOCOL,
        // Indicates whether the site is hosted on wordpress.com.
        // If false, then the asumption is made that the site is self hosted.
        // If true, then the plugin will source its content on wordpress.com using the JSON REST API V2.
        // If your site is hosted on wordpress.org, then set this to false.
        hostingWPCOM: false,
        // If useACF is true, then the source plugin will try to import the Wordpress ACF Plugin contents.
        // This feature is untested for sites hosted on Wordpress.com
        useACF: false,
        auth: {
          htaccess_user: process.env.AUTH_USER,
          htaccess_pass: process.env.AUTH_PASS
        },
        searchAndReplaceContentUrls: {
          sourceUrl: process.env.SOURCE_URL,
          replacementUrl: process.env.SITE_URL
        },
        verboseOutput: true,
        perPage: 10,
        concurrentRequests: 5,
        excludedRoutes: [
          "/akismet/**",
          "/disqus/**",
          "/jetpack/**",
          "/tho/**",
          "/*/*/comments",
          "**settings",
          "/yoast/**"
        ]
      }
    },
    {
      resolve: `gatsby-plugin-google-tagmanager`,
      options: {
        id: process.env.GTM_ID,
        includeInDevelopment: true
      }
    },
    {
      resolve: `gatsby-plugin-netlify`
    }
  ]
};

gatsby-node.js: N/A gatsby-browser.js: N/A gatsby-ssr.js: N/A

anantoghosh commented 6 years ago

I just started with an empty project and installed the sass plugin, which is throwing this error.

jquense commented 6 years ago

this may be due to something odd via #6352

nicolasbettag commented 5 years ago

Any update on this one?

jquense commented 5 years ago

The issue with the sass plugin was fixed yes.