Tips for including vue-autonumeric in your webpack 2 setup

Encountering a problem while bundling the vue-autonumeric package with Webpack 2, where the dependency AutoNumeric is not being found properly.

Although there is an alias set up in the configuration that works fine with webpack 3, it seems to fail when working on webpack 2 with a new project, showing this error message:

Hash: 470e79379d7394141898
Version: webpack 2.7.0
Time: 135ms
           Asset     Size  Chunks             Chunk Names
./dist/bundle.js  12.7 kB       0  [emitted]  main
   [0] ./~/vue-autonumeric/dist/vue-autonumeric.min.js 9.29 kB {0} [built]
   [1] ./src/vueAutonumericTest.js 120 bytes {0} [built]

ERROR in ./~/vue-autonumeric/dist/vue-autonumeric.min.js
Module not found: Error: Can't resolve 'AutoNumeric' in '/home/user/vueAutonum/node_modules/vue-autonumeric/dist'
 @ ./~/vue-autonumeric/dist/vue-autonumeric.min.js 1:82-104
 @ ./src/vueAutonumericTest.js

Attempted to solve this by adding:

  resolve: {
    alias: {
      AutoNumeric: 'node_modules/autonumeric/dist/autoNumeric.min',
    },
  },

to the webpack.config.js file for webpack 2, but unfortunately, it did not work as expected.

Any insights on why this issue occurs and how to make it functional for both webpack version 3 and 2?

For more details on this problem, please refer to this Github issue.

Answer №1

Here is the wrapper for umd in the bundle file of vue-autoNumeric:

if(typeof exports === 'object' && typeof module === 'object')
    module.exports = factory(require("AutoNumeric"));
else if(typeof define === 'function' && define.amd)
    define("VueAutonumeric", ["AutoNumeric"], factory);
else if(typeof exports === 'object')
    exports["VueAutonumeric"] = factory(require("AutoNumeric"));
else
    root["VueAutonumeric"] = factory(root["AutoNumeric"]);

It's clear that vue-autoNumeric relies on a module called 'AutoNumeric'.

Perhaps, adjustments to webpack config or updating package dependencies list as suggested in this Issue Comment are necessary.

Alternatively, you could include autonumeric in your dependencies list so that webpack can locate the missing module.

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

Generating output from a callback function in TypeScript

When I execute a graphql query, the showUsers function is supposed to display all users (styled as boxes). However, at the moment, nothing is showing up. I am utilizing a functional component instead of a class component. This function is invoked after m ...

Include the clicked link into the text input area using Ajax or Jquery

Hey there, I'm just starting out with jquery and ajax so please be patient with me. Below is a snippet of my script that fetches branch names from the database asynchronously: $(document).ready(function () { $("#pickup").on('keyup' ...

What is the best approach for retrieving values from dynamically repeated forms within a FormGroup using Typescript?

Hello and thank you for taking the time to read my question! I am currently working on an Ionic 3 app project. One of the features in this app involves a page that can have up to 200 identical forms, each containing an input field. You can see an example ...

What is the best way to configure dependencies for a production deployment when utilizing Babel within the build script?

From what I understand, Babel is typically used for compiling code, which is why it usually resides in devDependencies. However, if I incorporate the Babel command into my build script and want to run npm install --only=prod before running npm run build d ...

Displaying random characters in place of Angular 6 font awesome icons

Recently, I started a new project with the angular cli and incorporated font-awesome 4.7.0. After that, I included it as a dependency in my angular.json file. "styles": [ "./node_modules/font-awesome/css/font-awesome.min.css", "./node ...

Making numerous changes to a single field in mongoDB can result in the error message: "Attempting to edit the path 'X' will generate a conflict at 'X'."

Looking to streamline my update operation: private async handleModifiedCategoryImages(data: ModifiedFilesEventData) { this.categoryModel .findByIdAndUpdate(data.resourceId, { $pullAll: { images: data.removedFiles || [] } ...

Display or conceal a division underneath a dropdown menu based on selections retrieved from a SQL Server database

Presented here is my JavaScript code. function appendItemforPurchaseOrder() { debugger var rowNumber = parseInt($(".itemmapContainer").attr("data-rownumber")); rowNumber = isNaN(rowNumber) ? 1 : rowNumber + 1; var addNewItemDetailHtml = ...

How can I display an array of data with a changing name using a FlatList in React Native?

How can I render a list of array data with a dynamic name in a FlatList using React Native? Below is the list of data that I would like to display in the FlatList: const movies = [ { '4W2JJ0CLbvfLJzBUHORVaz6sAGv2': [ { name: ...

Creating a tooltip for a specific cell within an AG grid react component is a useful customization feature

How can I customize the tooltip for a specific row in my AG Grid? I see that there is a tooltipField available in ColDefs, but I want to provide a custom string instead of using a field value. Is there a way to achieve this customization? ...

I am looking to manage the error handling service, and my next step is to intentionally insert a single error into my service and have it automated

Need help with error handling in my service. I want to manually insert a single error, but would like it to be done automatically instead. 'use strict'; angular.module('nexoolApp.errorservice', ['nexoolApp.config']) .servic ...

Navigate to the following div, navigate back to the previous div

I am attempting to implement a div navigation system with next/previous buttons. Despite searching extensively on Google, I have not found the exact solution I am looking for. First and foremost, I want to maintain the integrity of my html structure. < ...

Can you embed a VueJs Component using jquery?

I have a complex application where I previously utilized jQuery to dynamically change views: $(function(){ $(".changeview").bind("click",function(){ $.post(linkAction,phpData,function(data){ $('#loa ...

Changing a single image within a v-for loop of images in Vue

I am currently working with an array in Vue where I am using v-for to create 3 columns of information. Each column includes an image, and I would like to be able to change only the specific image that is being hovered over without affecting any others. How ...

Using async/await with Middleware in Express

I'm struggling to grasp the concept of writing middleware in Express that uses async/await without leaving a floating Promise after execution. Despite reading numerous blogs and StackOverflow posts, it appears that there is a common pattern for utiliz ...

What steps can I take to prevent my menu items from overlapping in the mobile navigation menu?

I am currently working on creating a mobile menu, but I'm facing an issue where the menu items overlap when hovered over. Instead, I want the menu items to move downwards when hovered upon to prevent the text from overlapping. Below is the HTML code ...

Unable to be implemented using inline-block styling

I'm struggling to get these 2 elements to display side by side using inline-block, I've tried everything but nothing seems to work. Goal: First element Second element I attempted to modify the HTML code to see if it would yield any results, b ...

Capybara's attach_file function is not properly activating the React onChange handler in Firefox

Currently, I am conducting tests on the file upload feature of a React-built page. The page includes a hidden file input field with an onChange event listener attached to it. Upon selecting a file, the onChange event is triggered and the file is processed ...

display a container and navigate to the specific link

Greetings! Could someone please help me make this code function properly? I am attempting to display the DIV (slidingDiv) and navigate to the selected ANCHOR (#anchor-01 + #anchor-02 + #anchor-03)... However, the code currently only allows me to go to the ...

Enhance your <head> section by adding lines when utilizing Layouts within Iron Router

Is there a way to add more lines to the <head> section using Iron Router and layouts? Take for example, inserting the following code snippet into the <head>... <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=ed ...

What is the best way to update datatables in Laravel vuejs with fresh data?

Currently, I am utilizing datatables 1.10.19 within vue js and encountering an issue with refreshing the table post inserting new data into the database. Despite trying methods like clear, destroy, and draw, none seem to be effective in achieving the des ...