'Nuxt installation error : Rule can only have one resource source (provided resource and test + include + exclude)

I successfully installed Vuejs and Nodejs but got a problem when installing Nuxtjs. This is what I get. I already asked some friends but it didn't work. Thanks for your help ! :)

Error : Rule can only have one resource source (provided resource and test + include + exclude)

Rule can only have one resource source (provided resource and test + include + exclude) in {
  "use": [
    {
      "loader": "C:\\Users\\User\\Desktop\\JS\\my-first-project\\node_modules\\babel-loader\\lib\\index.js",
      "options": {
        "configFile": false,
        "babelrc": false,
        "cacheDirectory": true,
        "envName": "server",
        "presets": [
          [
            "C:\\Users\\User\\Desktop\\JS\\my-first-project\\node_modules\\@nuxt\\babel-preset-app\\src\\index.js",
            {
              "corejs": {
                "version": 3
              }
            }
          ]
        ]
      },
      "ident": "clonedRuleSet-30[0].rules[0].use[0]"
    }
  ]
}

  "use": [
  {
  "loader": "C:\\Users\\User\\Desktop\\JS\\my-first-project\\node_modules\\babel-loader\\lib\\index.js",
  "options": {
  "configFile": false,
  "babelrc": false,
  "cacheDirectory": true,
  "envName": "server",
  "presets": [
  [
  "C:\\Users\\User\\Desktop\\JS\\my-first-project\\node_modules\\@nuxt\\babel-preset-app\\src\\index.js",
  {
  "corejs": {
  "version": 3
  }
  }
  ]
  ]
  },
  "ident": "clonedRuleSet-30[0].rules[0].use[0]"
  }
  ]
  }
  at checkResourceSource (node_modules\@nuxt\webpack\node_modules\webpack\lib\RuleSet.js:167:11)
  at Function.normalizeRule (node_modules\@nuxt\webpack\node_modules\webpack\lib\RuleSet.js:198:4)
  at node_modules\@nuxt\webpack\node_modules\webpack\lib\RuleSet.js:110:20
  at Array.map (<anonymous>)
  at Function.normalizeRules (node_modules\@nuxt\webpack\node_modules\webpack\lib\RuleSet.js:109:17)
  at new RuleSet (node_modules\@nuxt\webpack\node_modules\webpack\lib\RuleSet.js:104:24)
  at new NormalModuleFactory (node_modules\@nuxt\webpack\node_modules\webpack\lib\NormalModuleFactory.js:115:18)
  at Compiler.createNormalModuleFactory (node_modules\@nuxt\webpack\node_modules\webpack\lib\Compiler.js:636:31)
  at Compiler.newCompilationParams (node_modules\@nuxt\webpack\node_modules\webpack\lib\Compiler.js:653:30)
  at Compiler.compile (node_modules\@nuxt\webpack\node_modules\webpack\lib\Compiler.js:661:23)
  at node_modules\@nuxt\webpack\node_modules\webpack\lib\Watching.js:77:18
  at AsyncSeriesHook.eval [as callAsync] (eval at create (node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:22:1)
  at AsyncSeriesHook.lazyCompileHook (node_modules\tapable\lib\Hook.js:154:20)
  at Watching._go (node_modules\@nuxt\webpack\node_modules\webpack\lib\Watching.js:41:32)
  at node_modules\@nuxt\webpack\node_modules\webpack\lib\Watching.js:33:9
  at Compiler.readRecords (node_modules\@nuxt\webpack\node_modules\webpack\lib\Compiler.js:529:11)



Solution 1:[1]

npm i -D webpack@^4.46.0 try this, it worked for me.

Solution 2:[2]

I've had the same issue today, it seems to be related to an npm dependencies resolution issue.

I have opened an issue in nuxt.js repository

In my project, the issue was present, cause of @nuxtjs/eslint-module, you can remove it and regen dependencies :

  • npm uninstall @nuxtjs/eslint-module
  • rm -rf node_modules package-lock.json
  • npm install

You will not longer have eslint feedbacks in your build command, but you can still use npm run lint, and you will be able to use nuxt until the issue will be fixed.

Solution 3:[3]

This happened to me when I installed the most recent version of copy-webpack-plugin in Nuxt v2 project. Apparently it doesn't use webpack5 so I had to downgrade copy-webpack-plugin to last compatible version e.g. [email protected]

Solution 4:[4]

I ran into this same error while trying to upgrade one of my old NuxtJS projects (using sass) built on node version 12 to version 16.

To fix this, i also installed @nuxtjs/style-resources that matches my versions of sass-loader and node-sass. To confirm, uninstall the ones you already have, and run

npm install --save-dev node-sass sass-loader@10 fibers @nuxtjs/style-resources

see this article for more

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 saif
Solution 2 Nainterceptor
Solution 3 ihorbond
Solution 4 Immanuel