Answer the question
In order to leave comments, you need to log in
How to install jquery in webpack?
Trying to install jquery via webpack
webpack.config.js
"use strict"
const path = require('path')
const webpack = require('webpack')
module.exports = {
plugins: [
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery"
}),
]
};
{
"name": "mp",
"version": "2.0.0",
"description": "Веб модуль с привязкой жителей к жилым зданиям",
"main": "index.js",
"scripts": {
"dev": "webpack --mode development",
"build": "webpack --mode production",
"watch": "webpack --mode development --watch",
"start": "webpack-dev-server --mode development --open"
},
"repository": {
"type": "git",
"url": "git+https://github.com/AlexandrRumiantsev/app_map.git"
},
"keywords": [
"6Exniskay20"
],
"author": "AlexWeber",
"license": "ISC",
"bugs": {
"url": "https://github.com/AlexandrRumiantsev/app_map/issues"
},
"homepage": "https://github.com/AlexandrRumiantsev/app_map#readme",
"devDependencies": {
"clean-webpack-plugin": "^1.0.0",
"css-loader": "^2.0.0",
"file-loader": "^2.0.0",
"html-webpack-plugin": "^3.2.0",
"image-webpack-loader": "^4.6.0",
"jquery": "^3.4.1",
"mini-css-extract-plugin": "^0.5.0",
"node-sass": "^4.10.0",
"optimize-css-assets-webpack-plugin": "^5.0.1",
"sass-loader": "^7.1.0",
"webpack": "^4.27.1",
"webpack-cli": "^3.1.2"
},
"dependencies": {
"bootstrap": "^4.3.1",
"jquery": "^3.3.1",
"popper.js": "^1.15.0",
"webpack-jquery-ui": "^2.0.1"
}
}
(function(){
"use strict";
import $ from 'jquery';
$(document).ready(function($) {
console.log('СЕРВЕР ЗАПУЩЕН');
});
})();
Answer the question
In order to leave comments, you need to log in
why do you node index.js
need it when you need it npm run start
for development and npm run build
for building sales. node index.js
launches the node with the index.js file, the node does not understand imports and gives an error.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question