Home > Net >  vue js import from node_modules
vue js import from node_modules

Time:02-10

I am new to vue js and currently trying to import any vue plugin/component into other sfc .vue files for usage.

Currently I am using VS code with vue create project cli setup and in my main App.vue file I am trying to import plugin after installation via npm.

I have came across this code at many places but not sure from where this has been imported. Also not sure how this path system works?

import SomePlugin from 'some-plugin';

My guess is that this comes inside node_modules folder after npm install cli part. Do we need to include full path of node_modules folder or vue-cli handles this automatically as full path looks weird.

import SomePlugin from '../node_modules/some-plugin';

CodePudding user response:

Importing using only the package name will always look in the node_modules folder, regardless of whether the node_modules is in the current directory, the parent directory, or the global directory. Unless if the path is preceded by ./, ../, etc. I think.

  • Related