Within the script section of my .vue file, I have the following code:
<script>
import get from 'lodash.get';
...
</script>
Despite trying to import lodash.get, I keep encountering an error message stating
ReferenceError: get is not defined
.
In contrast, in my entry file (app.js which is a standard js file), I am able to successfully execute the following:
import get from 'lodash.get';
window.get = get;
However, I would prefer to handle imports within each specific component.
Is there a method to import packages (such as lodash.get in this case) directly into a vue component?
My project directory structure looks like this:
node_modules
..lodash.get
....index.js
resources
..assets
....js
......components
........ComponentWhereINeedImport.vue
....app.js
Unfortunately, none of the following import attempts are successful:
import { get } from 'lodash/get';
import { get } from 'lodash.get';
import get from 'lodash/get';
import get from 'lodash.get';
require('../../../../node_modules/lodash.get/index.js');
require('../../../../node_modules/lodash.get/index');
require('../../../../node_modules/lodash.get');