Estoy tratando de usar un bootstrap simple, el complemento jquery bootstrap-show-password pero al cargar la página con el formulario muestra un error Uncaught ReferenceError: $ is not defined .
No entiendo por qué jquery no se cargaría. hice lo de siempre
npm install bootstrap jquery popper.js --save
y en mi app.js tengo
//import jQuery from "jquery"; //window.$ = window.jQuery = jQuery; // this should be loaded with webpack, right?! ^ import "bootstrap"; import "bootstrap-show-password"; Estoy mirando los documentos del paquete web y dice que use el proveedor del complemento, pero cuando lo agrego a mi webpack.config.js
new webpack.ProvidePlugin({ $: 'jquery', jQuery: 'jquery', }); npm run build me da TypeError: webpack.ProvidePlugin is not a constructor
¿Me perdí algo que necesita ser instalado?
Aquí están mis dependencias de package.json
"devDependencies": { "@babel/preset-env": "^7.12.17", "autoprefixer": "^9.8.6", "babel-loader": "^8.2.2", "browser-sync": "^2.26.14", "eslint": "^7.20.0", "eslint-loader": "^4.0.2", "htmlnano": "^0.2.8", "imagemin-cli": "^6.0.0", "node-sass": "^5.0.0", "npm-run-all": "^4.1.5", "onchange": "^7.1.0", "postcss": "^8.2.6", "postcss-cli": "^8.3.1", "posthtml": "^0.15.1", "posthtml-cli": "^0.9.1", "posthtml-modules": "^0.7.3", "stylelint": "^13.11.0", "webpack": "^5.23.0", "webpack-cli": "^4.5.0" }, "dependencies": { "bootstrap": "^4.6.0", "bootstrap-show-password": "^1.2.1", "jquery": "^3.5.1", "popper.js": "^1.16.1" }Bien, después de unas horas descubrí que el culpable se inicializó incorrectamente en webpack var en webpack.config.js . Por una razón que está más allá de mí, tenía allí
const { webpack } = require("webpack");en vez de
const webpack = require("webpack");