Although I typically work on backend development, I am now faced with the task of implementing something in an existing Vue codebase. In a file named myModal.vue
, I need to incorporate a JavaScript library called cron-parser. When I utilize it in the app.js
file, everything runs smoothly:
import CronParser from 'cron-parser';
let interval = CronParser.parseExpression('*/2 * * * *');
console.log(interval.next().toString()); // outputs a correct datetime
Now, my intention is to pass this CronParser to the myModal.vue
file. Following the example of injecting HighCharts, I added a third line out of these four:
Vue.prototype.$eventHub = new Vue();
Vue.use(HighchartsVue);
Vue.use(CronParser);
let myModal = require('./components/myModal.vue');
// and additional components
Subsequently, within myModal.vue
, I implement the same code:
let interval = CronParser.parseExpression('*/2 * * * *');
console.log(interval.next().toString());
However, I encounter the error:
"ReferenceError: CronParser is not defined"
I am feeling somewhat disoriented about where I might be making a mistake in this process. Could someone provide me with a clue in the right direction?