When i install bootstrap with npm, i ran folowing command:
- npm install bootstrap
- npm install popper.js --save
then i got the following directory tree:
-node_module
|__bootstrap
|__jquery
|__popper
and i use it:
<script type="module" src="<?php echo asset('node_modules/jquery/dist/jquery.min.js') ?>"></script>
<script type="module" src="<?php echo asset('node_modules/popper/dist/popper.min.js') ?>"></script>
<script type="module" src="<?php echo asset('node_modules/bootstrap/dist/js/bootstrap.min.js') ?>"></script>
<link rel="stylesheet" href="<?php echo asset('node_modules/bootstrap/dist/css/bootstrap.min.css') ?>">
but when i run it, it export an error:
Uncaught TypeError: Cannot set property 'bootstrap' of undefined
at bootstrap.min.js:6 at bootstrap.min.js:6
I dont know why, phease help!! My packeage.json:
{
"private": true,
"scripts": {
"dev": "npm run development",
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch-poll": "npm run watch -- --watch-poll",
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
"prod": "npm run production",
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
},
"devDependencies": {
"axios": "^0.16.2",
"bootstrap-sass": "^3.3.7",
"cross-env": "^5.0.1",
"jquery": "^3.3.1",
"laravel-mix": "^1.0",
"lodash": "^4.17.4",
"vue": "^2.1.10"
},
"dependencies": {
"bootstrap": "^4.1.3",
"popper.js": "^1.14.4"
}
}