Reveal Vue component functionality to external projects

Currently, I am researching ways to share my Vue component with other projects without the need to publish it on NPM.

I came across a helpful resource that explains how to publish a Vue component on NPM: how-to-publish-your-vue-js-component-on-npm-62b67dfb3e58

However, I prefer not to use NPM for this purpose. My goal is to utilize the created component in a different local project instead.

Answer №1

Create your own personal repository within your package.json

Your Library repository featuring .vue components

package.json

{
  "name": "my-personal-package-with-components",
  "version": "1.0.0",
  "files": [
    "lib/js/components/**.vue"
  ]
}

Integrating the components into your project

package.json

{
   "devDependencies": {
      "my-personal-package-with-components": "git+ssh://git@my/repo.git#master",
   }
}

To use the .vue files in your application, import them as follows:

import SpecialComponent1 from 'my-personal-package-with-components/lib/js/components/SpecialComponent1.vue';
import SpecialComponent2 from 'my-personal-package-with-components/lib/js/components/SpecialComponent2.vue';

Vue.component('special-component-1', SpecialComponent1);
Vue.component('special-component-2', SpecialComponent2);

For easier development, utilize npm link:

https://docs.npmjs.com/cli/v8/commands/npm-link

cd mylib/ && npm link
cd ../myapp && npm link mylib

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The error code EPROTO B8150000 indicates that the SSL routines have disabled unsafe legacy renegotiation, resulting in the error code 0A000152

Every time I attempt to install a package on NPM, I encounter the following error message; 47 verbose stack FetchError: request to https://artifactory.thy.com/artifactory/api/npm/kac-npm/@angular%2fcli failed, reason: write EPROTO B8150000:error:0A000152:S ...

The issue lies with the inability of single quotes to function properly within the

I am struggling to configure my package.json file on Windows 10 with npm 5.5.1 to run the command npm run test-watch. Here is how my package.json looks: "scripts": { "test": "mocha server/**/*.test.js", "test-watch": "nodemon --exec 'npm te ...

Incorporating Vuetify into a Vue CLI application with the help of webpack

I am facing an issue with my Vue CLI application that uses Webpack and Vuetify. The Vuetify components are not loading properly, and I keep getting the following warnings: Unknown custom element: < v-app > - did you register the component correctly? ...

Issues arise when attempting to install global NPM packages using a basic CircleCI 2.0 setup

My Dockerfile is functioning properly and includes the following commands: FROM node:10 RUN npm set unsafe-perm true RUN npm install -g '@oresoftware/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2a58184d6a1a041a041b1918 ...

The appearance of a Tom-select with the bootstrap 5 theme sets it apart from a bootstrap 5.1.3 styled select

Premise In order to ensure consistent display of selects across Windows, Linux, and Mac in my project, I have implemented the following combination: tom-select v2.0.1 JavaScript library; Bootstrap v5.1.3 frontend framework; Symfony v5.4.5 backend framewo ...

Why is my React app opening in Google Chrome instead of the API?

I have a link in my React app that is supposed to open a PDF in another page, but for some reason Google Chrome is redirecting me to the React application instead of opening the API endpoint that renders the PDF. The URL for the PDF is /api/file/:_id and m ...

Ember - connecting to a JSON data source

Recently, I have been following a tutorial/example from codeschool and everything is going well. However, the example code includes the line: App.ApplicationAdapter = DS.FixtureAdapter.extend(); Now, I want to maintain all the existing functionality but ...

Creating a line of functions pool in Javascript with a delay feature

Recently, I created a code snippet that simulates a function line. It involves calling functions such as fn1, delay, fn2, delay, and so on. The idea is to call a function, remove it from the line, have a short sleep, and repeat. However, I've encount ...

Pulling a WooCommerce variable in PHP: A guide for JavaScript developers

I'm having some trouble executing PHP code that utilizes the WooCommerce variable to retrieve the order ID. add_action('add_meta_boxes', 'gen_order_meta_boxes'); function gen_order_meta_boxes() { add_meta_box( 'wo ...

Clicking the mouse within three.js

I'm facing an issue with my webpage that features a three.js (webgl) graphic created using a .dae file imported from Blender. My goal is to draw a square or mark wherever the mouse is clicked, but for some reason, the square appears in a different loc ...

How come process.env.username is pulling the computer hostname (in Windows 10), rather than the key-value pair specified in the config.env file?

In my config.env file, I set up username and password variables and attempted to retrieve them using the dotenv package. However, when I try to access the username variable, it returns the hostname instead. This happens regardless of whether I use lowerca ...

Is it possible to determine if the user is able to navigate forward in browser history?

Is there a way to check if browser history exists using JavaScript? Specifically, I want to determine if the forward button is enabled or not Any ideas on how to achieve this? ...

Using jQuery can sometimes result in accidentally selecting multiple elements with the $(this) selector

Utilizing the .each() jQuery function alongside the $(this) selector to create a hover effect on a div, however, due to the proximity of the divs, the $(this) selector may select more than one element if the mouse movement is too fast. Is there a way to e ...

How to properly handle date property in a document when deserializing with Node.js

I am encountering an issue with saving documents in Couchbase that contain JavaScript Date values. I want to retrieve these values exactly as they are, without getting them back as strings like '2016-01-02T12:13:14Z'. After some research, I disc ...

Performing an HTTP POST request in Angular 2

After starting my work with Angular 2 and TypeScript, everything was going great. However, I encountered an issue when working with a REST API (POST) where the console log displayed Response {_body: "", status: 204, statusText: "Ok", headers: Headers, type ...

What sets TypeScript apart from AtScript?

From what I understand, TypeScript was created by Microsoft and is used to dynamically generate JavaScript. I'm curious about the distinctions between TypeScript and AtScript. Which one would be more beneficial for a JavaScript developer to learn? ...

The process of configuring a tab to appear automatically upon the webpage loading

Jsfiddle: http://jsfiddle.net/87YGW/ Presently, to display content for tab 1, I have to click on it. However, I want the tab 1 content to be shown automatically when the page is opened. HTML: <div id="tab2" class="css-tabs"> <ul class=" ...

The start screen fails to display when clicking the restart button

I am struggling to get the restart button to display the start screen again. Even though I have called the restart function within the clearColors function, which should show the start screen, it hasn't been effective so far. Initially, in the fadeOut ...

The Socket.io and express app are facing connectivity issues as a result of a CORS error stating: "It is not allowed to use the wildcard '*' in the 'Access-Control-Allow-Origin' header"

I'm going crazy over a trivial issue I've encountered. My socket.io/express app is deployed on Digital Ocean using Docker setup. To enable https, I'm utilizing Caddy within my Docker setup for automatic https. I've been attempting to ...

Deciphering the world of node modules

How can I effectively navigate node modules? In a nutshell, how do I explore a node module that I have installed to understand where to find what I need? When I install a node module like npm i googleapis, it downloads the Google APIs module. But how do ...