vue-cli: "Rule can only have one resource source" failure occurs when running server or building for production
Version
4.5.8
Environment info
System:
OS: macOS 10.15.7
CPU: (8) x64 Intel(R) Core(TM) i7-8569U CPU @ 2.80GHz
Binaries:
Node: 14.14.0 - ~/.nvm/versions/node/v14.14.0/bin/node
Yarn: Not Found
npm: 6.14.8 - ~/.nvm/versions/node/v14.14.0/bin/npm
Browsers:
Chrome: 86.0.4240.80
Edge: Not Found
Firefox: 79.0
Safari: 14.0
npmPackages:
@vue/babel-helper-vue-jsx-merge-props: 1.2.1
@vue/babel-helper-vue-transform-on: 1.0.0-rc.2
@vue/babel-plugin-jsx: 1.0.0-rc.3
@vue/babel-plugin-transform-vue-jsx: 1.2.1
@vue/babel-preset-app: 4.5.8
@vue/babel-preset-jsx: 1.2.3
@vue/babel-sugar-composition-api-inject-h: 1.2.1
@vue/babel-sugar-composition-api-render-instance: 1.2.1
@vue/babel-sugar-functional-vue: 1.2.2
@vue/babel-sugar-inject-h: 1.2.2
@vue/babel-sugar-v-model: 1.2.3
@vue/babel-sugar-v-on: 1.2.3
@vue/cli: ^4.5.8 => 4.5.8
@vue/cli-overlay: 4.5.8
@vue/cli-plugin-babel: ^4.5.8 => 4.5.8
@vue/cli-plugin-eslint: ^4.5.8 => 4.5.8
@vue/cli-plugin-router: 4.5.8
@vue/cli-plugin-vuex: 4.5.8
@vue/cli-service: ^4.5.8 => 4.5.8
@vue/cli-shared-utils: 4.5.8
@vue/cli-ui: 4.5.8
@vue/cli-ui-addon-webpack: 4.5.8
@vue/cli-ui-addon-widgets: 4.5.8
@vue/compiler-core: 3.0.1
@vue/compiler-dom: 3.0.1
@vue/compiler-sfc: 3.0.1
@vue/compiler-ssr: 3.0.1
@vue/component-compiler-utils: 3.2.0
@vue/preload-webpack-plugin: 1.1.2
@vue/reactivity: 3.0.1
@vue/runtime-core: 3.0.1
@vue/runtime-dom: 3.0.1
@vue/shared: 3.0.1
@vue/web-component-wrapper: 1.2.0
eslint-plugin-vue: ^7.1.0 => 7.1.0
typescript: 3.9.7
vue: ^2.6.10 => 2.6.12 (3.0.1)
vue-cli-plugin-apollo: 0.21.3
vue-codemod: 0.0.4
vue-eslint-parser: 7.1.1
vue-hot-reload-api: 2.3.4
vue-loader: 15.9.3 (16.0.0-beta.8)
vue-style-loader: 4.1.2
vue-template-compiler: ^2.6.10 => 2.6.12
vue-template-es2015-compiler: 1.9.1
npmGlobalPackages:
@vue/cli: Not Found
Steps to reproduce
npm install
vue-cli-service build
orvue-cli-service serve
What is expected?
To be built correctly
What is actually happening?
Error occurs:
Error: Rule can only have one resource source (provided resource and test include exclude) in {
"exclude": [
null
],
"use": [
{
"loader": "./node_modules/cache-loader/dist/cjs.js",
"options": {
"cacheDirectory": "./node_modules/.cache/babel-loader",
"cacheIdentifier": "d7e2daba"
},
"ident": "clonedRuleSet-38[0].rules[0].use[0]"
},
{
"loader": "/Users/vp/nuxeo/nuxeo-insight-ui/node_modules/babel-loader/lib/index.js",
"options": "undefined",
"ident": "undefined"
}
]
}
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 63
- Comments: 54 (4 by maintainers)
Commits related to this issue
- fixing the webpack resource bug (again) Ref: https://github.com/vuejs/vue-cli/issues/5986 — committed to rancher-sandbox/rancher-desktop by ericpromislow 3 years ago
- test access on store app2 | issue for npm build and webpack 5 Error: Rule can only have one resource source (provided resource and test ... https://github.com/vuejs/vue-cli/issues/5986 — committed to OlivierArgentieri/basic-webpack-vue by OlivierArgentieri 3 years ago
- fix(dependencies): downgrade sass & webpack š (#1109) linked to https://github.com/vuejs/vue-cli/issues/5986 — committed to weareopensource/Vue by PierreBrisorgueil 3 years ago
- Freeze versions of dependency packages Some bugs with sass-loader and webpack prevented building the project for dist. See https://github.com/vuejs/vue-cli/issues/5986 for more details. Freezing the... — committed to uwla/vue-data-table by uwla 3 years ago
- Update dependencies after audit Add webpack dependency because build fails ( see here https://github.com/vuejs/vue-cli/issues/5986 ) — committed to rsksmart/2wp-app by josedahlquist 3 years ago
- fix for bug https://github.com/vuejs/vue-cli/issues/5986 — committed to thinknimble/tn-spa-bootstrapper by paribaker 3 years ago
- Vue/Django Stack support (#3) * added new branch * removed test file * added mac version * updated django/vue * added tester code * added unwrap comment * readme.md * removed tem... — committed to thinknimble/tn-spa-bootstrapper by oudeismetis 3 years ago
- fix: gets an error when running 'npm run serve' after upgrading '@vue/cli-plugin-babel' from 4.5.16 to 5.0.4 Error: - UnhandledPromiseRejectionWarning: Error: Rule can only have one resource source (... — committed to beatrizsmerino/vue-editor by beatrizsmerino 2 years ago
- fix: gets an error when running 'npm run serve' after upgrading '@vue/cli-plugin-babel' from 4.5.16 to 5.0.4 Error: - UnhandledPromiseRejectionWarning: Error: Rule can only have one resource source (... — committed to beatrizsmerino/vue-users by beatrizsmerino 2 years ago
- fix: gets an error when running 'npm run serve' after upgrading '@vue/cli-plugin-babel' from 4.5.16 to 5.0.4 Error: - UnhandledPromiseRejectionWarning: Error: Rule can only have one resource source (... — committed to beatrizsmerino/vue-todolist by beatrizsmerino 2 years ago
- BUGFIX. Gets an error when running 'npm run serve' after upgrading '@vue/cli-plugin-babel' from 4.5.16 to 5.0.4 Error: - UnhandledPromiseRejectionWarning: Error: Rule can only have one resource sourc... — committed to beatrizsmerino/vue-todolist by beatrizsmerino 2 years ago
- BUGFIX. Gets an error when running 'npm run serve' after upgrading '@vue/cli-plugin-babel' from 4.5.16 to 5.0.4 Error: - UnhandledPromiseRejectionWarning: Error: Rule can only have one resource sourc... — committed to beatrizsmerino/vue-gh-pages by beatrizsmerino 2 years ago
- BUGFIX. Gets an error when running 'npm run serve' after upgrading '@vue/cli-plugin-babel' from 4.5.16 to 5.0.4 Error: - UnhandledPromiseRejectionWarning: Error: Rule can only have one resource sourc... — committed to beatrizsmerino/git-bible by beatrizsmerino 2 years ago
- BUGFIX. Gets an error when running 'npm run serve' after upgrading '@vue/cli-plugin-babel' from 4.5.16 to 5.0.4 Error: - UnhandledPromiseRejectionWarning: Error: Rule can only have one resource sourc... — committed to beatrizsmerino/git-bible by beatrizsmerino 2 years ago
Can people stop posting the āsolutionā of not using webpack 5? Itās not that new anymore, and many packages require it.
Vue needs to support this.
I can confirm that downgrading to
"webpack": "^4.45.0"
worksIt can be resolved with the following commands
npm uninstall sass-loader
npm install sass-loader@^10.1.1 --save-dev
If the version of webpack is 5 then downgrade to any version between 4 and 5npm uninstall webpack
npm install webpack@^4.0.0 --save-dev
For me this issue appeared after updating my
sass-loader
. Fixed by downgrading to"sass-loader": "^10.1.1"
The problem still exists, and thatās really infuriating. The solution is NOT to downgrade to a lower version of webpack or whatever package. One should be able to use it with node 16 (indeed, if you want to use this version, webpack 5 is required by some other packages).
This is getting ridiculous. I also have this problem. I just reverted old packege-lock.json and it works.
Why It was possible to properly install dependencies few weeks ago and now it is not possible? I even didāt change anything!
Itās insane how fragile our dependencies are.
je veux migrer du version 4 Ć 5 , donc la solution proposer au dessus ne me convient pas, y a t il une autre solution ?
Itās not a node version issue but a webpack v5 issue
npm uninstall webpack npm install webpack@^4.0.0 --save-dev
Is downgrading to Webpack 4.x.x a good solution?
For what itās worth, I was having the same issue. Latest npm 7 handles peer dependencies in a different way than npm 6.
Following some advice in https://github.com/nuxt/nuxt.js/issues/8277 I ran
npm i --legacy-peer-deps
which drops webpack 5 from mypackage-lock.json
and the build now works as expected.This error raises by combination of
@vue/cli-plugin-babel
andvue-loader
āsplugin-webpack5.js
. webpack 5 looks reject combiningtest
/include
/exclude
withresource
, andplugin-webpack5.js
always add defaultresource
function.Here is the project example (sorry its dirty but simple) - https://github.com/vpasquier/vuejscli-repro
The problem is related to webpack 5 (https://github.com/vpasquier/vuejscli-repro/blob/master/my-project/package.json#L20)
This is the only thing iāve added as dependency from the default vuejs bootstrap. Iāve reverted my project to 4.x.x and it works well. They have released recently.
This worked well for me on vue3 and TypeScript setup
Dialing it back to
"sass-loader": "^10.1.1"
inpackage.json
worked for me. I appear to be onwebpack@4.46.0
already.Just confirmed this with an actual project. It works with Webpack 4.44.2 but fails with anything 5.x.x
This doesnāt solve the described issue, is only a bandaid
Totally agree with @zawadsoon. It is incredible how we are overexposed to dependencies. From a project up and running to a project full of unknown errors due to 3rd party libs.
None of those actually worked for me.
But Vue should support Webpack 5.x or at least provide instructions on how to configure Webpack 5.x
Just in case anyone has the issue I had with this, I thought I would share.
Basically for me, the problem was due to one package I was using having a dependancy on css-loader, which since version 6, has moved to using webpack 5. I suspect this will keep happening while packages update to using webpack 5, so it may be a different package for you.
I could see the problem when trying to add webpack 4.46.0 as a dev dependancy
npm i webpack@4.46.0 --save-dev
I then checked the version css-loader switch to using webpack 5 and then included the version before as a dev dependancy.npm i css-loader@5.2.7 --save-dev
. I could then also include webpack 4 as a dev depenadancy and everything was working again.What a nightmare!! Hope that helps someone!!
Updating vue/cli* to >= 5.0.0-rc.1 solves this issue can i can now use webpack 5 and sass-loader > 10.2 The alternative is to downgrade to webpack 4 and sass-loader 10.2 Thanks, syldman.
This worked for me. Thank you
all solution above not works for me.
Mine is the monorepo repository. After webpack (4/5) is referenced in a package, the CLI cannot be started, and these two packages must be deleted.
At first I thought it was a webpack 5 problem until I switched back to webpack 4, the problem still existed.
For me, vue-cli is really a black box
I found a solution but in my case I believe it was somewhat related to the Quasar Framework dependencies my project was using. But here are some steps that helped me out:
I started using Node v12 (which is recommended by many frameworks as it is the last LTS version released) and forced the project to use ācore-jsā dependency in version 3, Iāve also seen some folks saying that version 2 also worked for them, but for me it only worked on 3.
I discovered that my problem specifically was related to the Quasar Framework getting updated to v2, and that there are plenty of modifications one has to do to make the project work correctly. If you are using Quasar, I highly recommend you to check this version upgrade tutorial: https://quasar.dev/quasar-cli/app-upgrade-guide
@shadow7412 it shouldnāt matter which version Iām using. Vue should use whichever version it wants
I also have this issue in a laravel-mix powered vue project. Getting all kinds of dependency errors and it looks like laravel-mix is doing something.
In my case the issue was with the cache-loader that couldnāt work along webpack v5 and vue/cli v4.x requires cache-loader. vue/cli v5 moved to webpack 5 and vue/cli v5.0.0-beta.3 dropped requirement for cache-loader. So updating both webpack and vue/cli to v5 solved the issue. Now everything is working fine.
Worked for me!
Having the same issue, moving from Node version 15 to 14 didnāt work for me. Here is the exception I am getting
Thanks for submitting this issue! Due to our limited time, we ask you to include a reproduction link to a minimal full reproduction of your problem (for example in a GitHub repository) so we can find what is causing the issue. Thank you for your understanding!