1

I am learning Vue.js. So i did install vue.js in my system using vue cli. it installed successfully. now i am creating a website in vue.js. so i am templating of this static HTML to vue.js. so i am using jQuery and some other libraries and js files in this HTML. so when i am importing "jquery.min.js" form my src/assets/js" folder then its not compiling and running development server. it is stuck on 40% every time but when i am installing jquery and then import its compiling and starting development server. so my question is Why need to install jQuery and other node modules? Why we can not use them just using import from .js files. I am also sharing some screen shots so you will be understand better.

Thanks in advance for help.

main.js file

import Vue from 'vue';
import App from './App.vue';

import './assets/css/bootstrap.min.css';
import './assets/css/green-audio-player.css';
import './assets/css/icofont.css';
import './assets/css/jquery.calendar.css';
import './assets/css/swiper.min.css';
import './assets/css/main.css';
import './assets/js/jquery.min.js';
import './assets/js/bootstrap.min.js';
import './assets/js/green-audio-player.js';
import './assets/js/popper.min.js';
import './assets/js/swiper.min.js';


Vue.config.productionTip = false;

new Vue({
    render: h => h(App)
}).$mount('#app');

main.js file code

Stuck error

1 Answer 1

1

The line

import './assets/js/jquery.min.js';

Will try to import a javascript module from that file, but that file is probably not the modular version, it's probably the version that's designed to be used in a script tag, e.g.

<script src='/assets/js/jquery.min.js'></script>

So you either need to move your non-modular javascript to script tags in the index.html, or use npm to install the modular version and then import the modules.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.