What is the process for importing fresh components from node_modules into the project?

Help! I've been using Webpack and WordPress for a while, but recently decided to dive into Vue.js. The problem is, I'm completely lost. I managed to integrate Vue with WordPress and Webpack after 5 days of work, but I still don't understand how it all fits together. Now, I'm stuck trying to use Flicking with yarn in my Vue project and I feel like I'm drowning. With so many layers of complexity, I have no idea where to start troubleshooting. Can someone please lend a hand?

I'm encountering the following error:

Uncaught Error: Cannot find module '../../node_modules/@egjs/vue-flicking' at webpackMissingModule (frontend.js?ver=1.1:17476:50) at Object../node_modules/babel-loader/lib/index.js!./node_modules/vue-loader/dist/index.js??ruleSet[1].rules[9].use[0]!./assets/src/stickyButton.vue?vue&type=script&lang=js

Here's a snippet of my file structure (excluding irrelevant files and folders):

.
└── theme-folder/
    ├── frontpage.php (where the component is being used)
    ├── node_modules
    ├── package.json (and lock files and such)
    └── assets/
        └── src/
            ├── sass/
            │   └── frontend.scss
            ├── js/
            │   ├── frontend.js
            │   └── header.js
            └── stickyButton.vue           

stickyButton.vue

<template>
    <div class="wrapper">
      <Flicking :options="{ renderOnlyVisible: true }">
        <div v-for="idx in list" class="flicking-panel" :key="idx">{{ idx }}</div>
      </Flicking>
      <div class="block is-flex is-justify-content-center">
      <span class="button mr-2 is-info is-outlined" @click="() => {
        list.splice(0, 0, ...[list[0] - 2, list[0] - 1]);
      }">Prepend</span>
        <span class="button mr-2 is-info is-outlined" @click="() => {
        list.push(list[list.length - 1] + 1, list[list.length - 1] + 2);
      }">Append</span>
      </div>
    </div>
</template>

<script>
import * as Vue from 'vue';
import VueFlicking from "../../node_modules/@egjs/vue-flicking";
Vue.use(VueFlicking);

export default {
  name: "stickyButton",

  data() {
    return {
      list: [0, 1, 2, 3, 4]
    }
  }
}

</script>

<style scoped>
@import url("../../node_modules/@egjs/vue3-flicking/dist/flicking.css");
// Extra css code omitted
</style>

Webpack compiles all the js and outputs in frontend.js:

// WP stuff
import "../sass/frontend.scss"
import "../js/header.js"

//start of vue stuff
import * as Vue from 'vue'
import Flicking from "@egjs/vue3-flicking";
import stickyButton from '../stickyButton.vue'
import { createApp } from 'vue'
const app = createApp(stickyButton)
app.mount('#stickyButton')

I've hit a roadblock and I'm feeling overwhelmed. Any guidance or assistance on why I'm getting this error would be highly appreciated. Thank you!

Answer №1

To import VueFlicker locally, the official documentation provides the following example:

<script>
import { Flicking } from "@egjs/vue-flicking";

export default {
    name: "stickyButton",
    components: {
        Flicking: Flicking,
    },
    data() {
        return {
            list: [0, 1, 2, 3, 4]
        }
    }
}
</script>

For styling:

<style scoped>
@import url("/node_modules/@egjs/vue-flicking/dist/flicking.css");
// Additional CSS code may be included here
</style>

You might need to adjust your webpack.config.js file to resolve the path to node_modules:

// inside webpack.config.js
const path = require('path');
module.exports = {
  //...
  resolve: {
    modules: [path.resolve(__dirname, 'node_modules'), 'node_modules']
  }
};

Refer to webpack.js.org/configuration/resolve/ for more information.

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

Enabling cross-origin requests using Express JS and the power of HTML5's fetch()

How do I enable cross domain requests using ExpressJS server and Javascript's fetch? It seems like there might be an issue with the client-side fetch() function because the response headers include Access-Control-Allow-Origin: *. I attempted to resol ...

Utilizing ExtJS and its control feature

I am facing an issue with the following code block: run: function(e, row){ var me = this; var container = Ext.getCmp('centercontainer'); try { container.removeAll(); } catch(e) { } // The code snippet below is act ...

I'm curious about where to find more information on this new technology called the 'scroll to page' feature

Recently, I came across a captivating website feature that caught my eye. As someone relatively new to front end web development, I am intrigued by the scrolling technique used on this site. I'm specifically drawn to the 'page to page' scro ...

Why do flex justifyContent and alignItems not have an effect on child <View/> components in React Native?

I am encountering an issue in React Native where a child view inside another view is not centering in the middle of the page. However, if the child view is not nested inside the parent view and stands alone, it does center properly in the middle of the pag ...

Unusual case of missing lines while reading a file using readline.createInterface()

const readline = require('readline') const fs = require('fs/promises'); (async function() { await fs.writeFile('/tmp/input.txt', [...Array(100000).keys()].join('\n')) await fs.writeFile('/tmp/other.tx ...

Listening for Vue events when the mouse is held down

Is there a way to adjust the boolean value when the mouse click is pressed and released? In my Vue project, I currently have v-on:mousedown="hold = !hold", but this setup toggles the boolean instead of requiring the user to hold down the click. ...

What is the best way to incorporate the .then method in a promise?

I'm currently working on some JS Express code that looks like this: app.get('/lists2', (req, res) => { mongo.getDB() .then(db => db.collection('dogs')) .then(collection => collection.find().toArray()) .then ...

Using setInterval in React within an onChange event

I am facing a challenge where I need to set a setInterval inside an onChange event, which is typically done in componentDidMount. Currently, I have 2 dropdowns that filter data and then render a table. The dropdowns are controlled by their respective onCh ...

How can I display table rows along with their child table rows in Angular?

Is there a way to display API data in a table using Angular? The table should have collapsible rows with nested child rows. This is the JSON file structure: { "collapse1": [ { "name": "Soil", "budget": 12345, "child": [ { ...

The code for 'infinite scroll' is currently only functional for scrolling at the top

I have implemented a piece of JavaScript code that is supposed to detect when the user has scrolled to the bottom of the document: $(window).scroll(function() { if ($(window).scrollTop() == $(document).height() - $(window).height()) { ...

Using VueJS to assign data within a method function

Below is the HTML code that I have written: <div id="myApp"> <div class="items"> <div class="item" v-for="quiz in quizzes" :key="quiz.id"} <span>{{ quiz.question }}</span> <span v-if="selected[quiz. ...

Tips on integrating JSON with JQuery

I'm currently developing an application that involves making a POST ajax request to a PHP script on my server. This script will query the database and retrieve a row of records in the form of an array. Each row will consist of elements such as id, tit ...

Can you guide me on switching between windows using the selenium IDE?

Instructions for handling popup windows in Selenium 2 (WebDriver) can be found at the following link: The instructions state that testing popup windows in Selenium 2 involves switching the driver to the popup window and then running the corresponding acti ...

Failure of Gulp Dest() to Generate File Output

Struggling to make gulp.dest output correctly. I'm aiming to output to the root of an ASP.NET Core project that I'm repurposing for TypeScript development. Any guidance on how to achieve this would be greatly appreciated. Below is the current con ...

Showing information on a grid using ejs and express

My goal is to display news articles using the NewsAPI in a grid format, with each grid item randomized in appearance. However, I'm encountering an issue where I only receive one instance of data from express for each loop iteration, resulting in grids ...

Attempting to conceal image formatting when an image is not available - ACF images customization

When designing my Content Page Template, I added borders, backgrounds, and box shadows to style the images. However, if the optional image field is left empty, it still displays a small box with the css styling. I have been trying to figure out how to hide ...

Issue with CSS and JS Files in Subdomains

I have implemented the following rules in my .htaccess file: RewriteEngine on RewriteCond %{HTTP_HOST} !^www\. RewriteCond %{HTTP_HOST} ^(.*)\.domain\.com RewriteRule ^(.*)$ index-merchant.php?id=%1 [L,NC,QSA] When I access trytry.domain.c ...

The ion-slide-box does not update after the active-slide has been changed using $index

I'm currently facing an issue with the controller that corresponds to this specific view. .controller('MenuCtrl', ['$rootScope','$scope','$state','$timeout','$ionicSlideBoxDelegate', functio ...

Implementing Material UI Slider component to update state upon mouse release, enabling real-time sliding functionality

Is there a way to update the new state only upon mouse release for a Material UI slider, while still allowing real-time tracking of the slide? Material UI offers two events: onChange and onChangeCommitted. The latter gives the desired end result, but the s ...

Excluding node modules when not included in tsconfig

Within my Angular project, there is a single tsconfig file that stands alone without extending any other tsconfigs or including any additional properties. Towards the end of the file, we have the following snippet: "angularCompilerOptions": { ...