The function $.fn.dataTable.render.moment does not exist in npm package

I have encountered an issue with my application that I am struggling to solve: I want to format dates in my data table using Moment.js like I have done in the following script:

$().ready(function() {
    const FROM_PATTERN = 'YYYY-MM-DD HH:mm:ss.SSS';
    const TO_PATTERN   = 'DD/MM/YYYY HH:mm';

    // list of documents - INDEX 
    var listDocuments = $("#list-documents").DataTable({
        processing:true,
        serverSide:true,
        scrollY:620,
        autoWidth:true,
        pageLength:25,
        responsive:true,
        scroller: {
            loadingIndicator:true 
        },
        ajax: {
            url: $("#list-documents").attr('data-json')
        },
        columns: [
            {data:'nom',name:'nom'},
            {data:'uri',name:'uri',
            "fnCreatedCell": function(nTd,sData,oData,iRow,iCol) {
                $(nTd).html("<a href='" + oData.uri + "'>"+ oData.uri +"</a>")
            }
        },
            {data:'updated_at',name:'updated_at',
            render: $.fn.dataTable.render.moment(FROM_PATTERN,TO_PATTERN),
        },
            {data:'action',name:'action',orderable:false,searchable:false},
        ]
    })
    .on('draw',function() {
        $("[data-toggle='tooltip']").tooltip()
    })
})

The problem I am facing is the error message

$.fn.dataTable.render.moment is not a function
. I am using Laravel 8.54 with laravel-mix. Here is my app.js file where I load the libraries:

require('./bootstrap');

$('.toast').toast('show')

$(function () {
    $('[data-toggle="tooltip"]').tooltip()
})


window.$ = window.jQuery = require('jquery')
window.toastr = require('toastr')

require('moment')
require('../../node_modules/datatables.net/js/jquery.dataTables.js')
require('datetime-moment')
require('../../node_modules/datatables.net-bs4/js/dataTables.bootstrap4')
require('../../node_modules/jquery-ui/ui/widgets/autocomplete.js')
require('../../node_modules/jquery-ui/ui/widgets/sortable.js')
require('datatables.net-responsive')

I am reaching out for help because I have searched online but most solutions do not involve npm. Has anyone else encountered this issue before? Thank you in advance.

Answer №1

This code snippet is part of a plugin available on datatables.net

If you're interested, you can access it by following this link:

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

Thumbnail Option in the WordPress Media Uploader

Is it possible to add support for selecting image size (thumbnails) in the Media Library popup created using the wp.media() function in WordPress? I am currently using WordPress 4.5.2 and my code sample is as follows: wp.media.frames.selectFile=wp.media( ...

discovering obscured information using jquery

I am working on a code snippet where I need to hide the detailed content for display purposes and only show it during printing: <div> <ul> <li> <span style="font-size: 1.25em;"> <strong> ...

Unable to execute the grunt command in Windows Command Prompt

After setting up Node.js on my Windows machine, I managed to run the 'node -v' and 'npm -v' commands successfully. I also used the 'npm -g grunt-cli' command to install Grunt globally. However, when I tried to use the Grunt co ...

Syntax highlighting in custom blocks with VueJS

Vue single file components allow for the creation of custom blocks (besides the commonly used script, template, and style). For more information, you can refer to the official documentation here: . However, I am struggling to enable syntax highlighting w ...

NodeJS server connection delay

My server has an Express NodeJS instance installed. The API stops responding when it is overloaded, leading to the following response: POST /my/api/result - - ms - - I attempted the following in ./bin/www: server.on('connection', function(sock ...

Troubleshooting issue with jQuery animate not correctly scrolling

I am experiencing an issue with my jQuery code that is supposed to scroll a smaller container element within a larger container element when a button is clicked. Despite testing with an alert and verifying that the code is working, the scrolling functional ...

Leveraging functions with Ng-Repeat

I am currently dealing with two different arrays of objects. The first array contains a list of permissions groups, while the second array consists of user groups. My main goal is to compare the Group Owner (which is represented by ID 70) with the list of ...

Installing npm for every project consumes a significant amount of storage space on the drive

Is there a way to direct npm install to a specific location on the hard drive so that when I run npm install, it creates a node_modules folder in that designated location? And when I launch a project, it pulls dependencies from that same location, essentia ...

Getting started with NPM is a breeze when you know how to install the contents of a repository into

While browsing, I stumbled upon a question that almost fit my needs: How to npm install to a specified directory? In my repository, I have all my sass boilerplate that I regularly use in various projects. I am looking for a way to incorporate it into my p ...

WebpackError: The global object "document" could not be found

I am encountering an issue with my website build using gatsby.js and bulma. While building the site, I receive the following error message: WebpackError: document is not defined The only instance where I use document is for the navbar-burger toggle code ...

Leveraging swagger v3 in YAML format, along with multiparty form-data and a node.js backend, to facilitate seamless file uploads

Why is there a difference in the functionality of this node.js file upload code when using jade compared to swagger? I have been experimenting with uploading files using swagger (yaml), multiparty, form-data, and nodejs. I came across a nodejs example fo ...

Refreshing webpage content by utilizing iframes

I am looking for a way to completely clear a webpage using either Javascript or PHP. However, there seems to be an issue with a specific area of the page that is marked as: data-form="manual iframe" When attempting to clear the page, only the data within ...

Component failing to refresh with each key modification

My understanding is that adding a key attribute to a component should make it reactive when the key changes. However, with a v-navigation-drawer from Vuetify, this doesn't seem to have any impact. I've tried making arbitrary changes to the logge ...

Unable to retrieve JSON data from converting TXT using JavaScript, resulting in undefined output

After converting txt to JSON, I encountered an issue. const txt = JSON.stringify(`{ ErrorList: [{ 80: 'Prepared' }], Reference: [ { 'Rule Name': 'Missing 3', 'Rule ID': 1, 'Rule Des& ...

Attempting to execute Ionic 2 within Visual Studio 2015

I am facing an issue while setting up my first Ionic 2 project in Visual Studio 2015. Every time I try to run the project, I encounter the following error message... "You're almost ready! If you're seeing this page, then you still need to instal ...

Converting string to JSON format by splitting it based on names

I recently manipulated a string containing the values "title:artist" by utilizing the str.split method : res = song.split(":"); The resulting output is as follows: ["Ruby","Kaiser Chiefs"] Now, I am curious about how to include the name in this array f ...

The error message encountered on Github Actions appears as follows: "bash: line 3: npm: command not

I am facing a challenge deploying a nodejs application from GitHub to a remote Ubuntu server via SSH. Below is the content of my main.yml file: name: Node Github CI on: push: branches: - master jobs: deploy: runs-on: ubuntu-latest ...

Is there a way to access the DOM's HTML during a test using JavaScript and Selenium WebDriver?

We are utilizing the Selenium webdriver manager version 12.1.7 alongside protractor 5.4.3 to facilitate the development of end-to-end tests for our Angular 9 application. Within our package.json, I have configured the following setup for executing our e2e ...

Launching npm start does not automatically open a browser tab

I'm currently learning angularjs 2 and I'm eager to create my first application using the framework. Following the guidelines on their official website, I proceeded with all the steps outlined in this link. In step 6, I am required to run the com ...

When attempting to install grunt on nodeenv with npm, you may encounter a findup-sync error

After setting up a node virtualenv with nodeenv, I execute source /bin/activate to switch to the correct directory, update npm, and run npm install -g grunt or npm install -g grunt-cli, but I continue to encounter the same error: npm ERR! Linux 3.13.0-53 ...