lela_98
lela_98

Reputation: 61

difference between the import paths in vue

I am starting to get into vue and I dont exactly understand the syntax between the different imports. For example it is possible to import something like this

import Vue from 'vue'; 
import axios from 'axios';

Where do you get the vue/axios from it confuses me a little because normally you would get it from a path. I'm sorry if this is answered elsewhere I couldn't find something. Thank you in advance :-)

Upvotes: 0

Views: 234

Answers (2)

Dan Knights
Dan Knights

Reputation: 8368

If you look in package.json you have a list of dependencies:

{
    "name": "resources",
    "version": "0.1.0",
    "private": true,
    "scripts": {
        "serve": "vue-cli-service serve",
        "build": "vue-cli-service build"
    },
    "dependencies": {
        "axios": "^0.20.0",
        "core-js": "^3.6.5",
        "vue": "^2.6.12",
    },
    "devDependencies": {
        "@vue/cli-plugin-babel": "~4.5.6",
        "@vue/cli-service": "~4.5.6",
        "sass": "^1.26.11",
        "sass-loader": "^10.0.2",
        "vue-template-compiler": "^2.6.12"
    },
    "browserslist": [
        "> 1%",
        "last 2 versions",
        "not dead"
    ]
}

These are npm packages installed using npm i <package>, they're present in your node_modules folder. You don't need relative paths for them, you just import them how you have in your snippet and node knows where to look.

Upvotes: 1

Maarten Veerman
Maarten Veerman

Reputation: 1621

How paths are resolved is defined and configured by the loader, in the case of Vue this is often Webpack.

You may find detailed information here: https://webpack.js.org/concepts/module-resolution/

Upvotes: 1

Related Questions