sysace's avatar

Removing jQuery in bootstrap-vue app

I'm trying to remove jquery since I'm not using it at all on my laravel-vue application. This can be read from bootstrap-vue.js.org:

"If Bootstrap is the only thing relying on jQuery, you can safely remove it — BootstrapVue does not depend on jQuery".

Below is the error seen after removing jquery from package.json and the references I have been able to find, when running npm run:

ERROR in ./node_modules/bootstrap/dist/js/bootstrap.js
Module not found: Error: Can't resolve 'jquery' in '/var/www/html/webapp-test/node_modules/bootstrap/dist/js'
 @ ./node_modules/bootstrap/dist/js/bootstrap.js 7:82-99
 @ ./resources/assets/js/bootstrap.js
 @ ./resources/assets/js/app.js
 @ multi ./resources/assets/js/app.js ./resources/assets/sass/app.scss

I aslo removed the node_modules folder and reference to jquery, window.$ = window.jQuery = require('jquery'); in bootstrap.js, but the same error is still there.

This is my dependencies in package.json:

    "devDependencies": {
        "axios": "^0.17",
        "cross-env": "^5.1",
        "jquery": "^3.2", // I want to remove this
        "laravel-mix": "^1.0",
        "lodash": "^4.17.4",
        "vue": "^2.5.7",
        "prettier": "^1.12.1"
    },
    "dependencies": {
        "bootstrap-vue": "^2.0.0-rc.11",
        "vuex": "^3.0.1"
    }

Any ideas?

0 likes
3 replies
rin4ik's avatar

this should help

npm install --save resolve-url-loader --dev
Cronix's avatar
Cronix
Best Answer
Level 67

what does your webpack.mix.js file look like? It appears that you're still using /node_modules/bootstrap/dist/js/bootstrap.js in there, which isn't the vue version of bootstrap, it's the real bootstrap.

sysace's avatar

I removed require('bootstrap'); from assets/js/bootstrap.js, and now it works.

Please or to participate in this conversation.