The module specifier "tslib" could not be resolved due to a TypeError. It is necessary for relative references to begin with either "/", "./", or "../"

Hey there, I recently started learning npm. I'm trying to install "@fullcalendar" and use it, but I keep getting this error message: "Uncaught TypeError: Failed to resolve module specifier "tslib". Relative references must start with either "/", "./", or "../"."

Here is the structure of my files: www/templates/node_modules/ www/templates/assets/calendar.js

This is the beginning of my calendar.js file:

import {Calendar} from '../node_modules/@fullcalendar/core/main.js';
dayGridPlugin from '../node_modules/@fullcalendar/daygrid/main.js';
timeGridPlugin from '../node_modules/@fullcalendar/timegrid/main.js';
listPlugin from '../node_modules/@fullcalendar/list/main.js';

other code

The error occurs when importing {Calendar}. Looking at @fullcalendar/core/main.js, I see:

import './vdom';
import { __extends, __assign } from 'tslib';
import { render, createElement, CalendarRoot, CustomContentRenderContext, CalendarContent, flushToDom, DelayedRunner, CalendarDataManager, isArraysEqual, applyStyleProp, CalendarApi } from '@fullcalendar/common';
export * from '@fullcalendar/common';

I believe the path to tslib (and other imported libraries) is incorrect. However, tslib is located in the directory www/templates/node_modules/tslib. I don't want to edit the installed package directly as I don't think that's the right approach. Is there a way to set the path in the npm config? Or what would be the best course of action?

Thank you, A.

Answer №1

It appears that the way you are importing your modules is incorrect. You do not have to include the entire path to your node modules. Instead, you can simply import them like this:

    import Calendar from '@fullcalendar/core';
    import dayGridPlugin from '@fullcalendar/daygrid';
    import timeGridPlugin from '@fullcalendar/timegrid';
    import listPlugin from '@fullcalendar/list';

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

Issue with getStaticProps not updating fetched values in Next.js production environment

I am currently working on building a blog using Next.js. Since the back-end is taken care of by another team, I am utilizing fetch API calls in getStaticProps to retrieve my articles, even though it may be considered best practice to interact with the data ...

Displaying selected values in a Multi Select Listbox upon submission of the same form when an error occurs

When the page is first loaded: Retrieve the values from the table field and store them in a variable If the field is blank, do not take any action Populate the listbox with default custom values When the form is submitted (on the same page) and multipl ...

The onChange method seems to be malfunctioning when used with radio buttons

I'm having an issue with my form's radio button. It is supposed to do something when the selected item changes, but it only works when the page first loads and not when I select a different item. Below is the code snippet: <div key={item} cla ...

How can JQuery be utilized to extract the information stored in the "value" parameter of a chosen option?

I have a dropdown menu that dynamically populates its options with numbers. Here is the code for that: <select name="TheServices" id="services-selector"> <option value="" disabled selected hidden>Static Select ...

npm error: The package name "__init__.py" is invalid because it cannot begin with an underscore character

Having trouble running a cucumber/gherkin script from Jenkins with Node.js? When attempting to execute the gherkin script, I encountered an error message: npm ERR! Invalid package name "init.py": name cannot start with an underscore package.json { &q ...

Tips for utilizing MUI Typography properties in version 5

I'm clear on what needs to be done: obtain the type definition for Typography.variant. However, I'm a bit uncertain on how to actually get these. interface TextProps { variant?: string component?: string onClick?: (event: React.MouseEvent&l ...

position text to the right side of a slider gallery created with JavaScript

I'm currently utilizing a WordPress plugin known as Slideshow Gallery and I want to position the text below it to float next to the gallery on the right side. I've attempted the following: .bioText{ font-size: 14px; font-size: 1.428571429rem; ...

"Encountering an error in Vue.js when trying to dynamically access nested arrays: push function not

My goal is to have two buttons displayed when a user uploads data: one for old products and one for new products. When the user clicks on either button, the corresponding products will be uploaded as 'old_product' or 'new_product'. Howe ...

Use column formatting for the table's body section

I have written the code below in HTML to create a table. I am looking to apply a specific style to the table body elements in a column that has been assigned a CSS class, while excluding the header columns from this style application. As an example, I hav ...

Can you provide a guide on setting up and utilizing mathlive within NuxtJS?

Can anyone assist me? I am trying to figure out why my code is not working or if I have implemented it incorrectly. I used npm i mathlive to obtain input. However, following the instructions for implementing nuxt plugins in the documentation has not yield ...

Tips for integrating TypeScript with Vue.js and Single File Components

After extensive searching online, I have struggled to find a straightforward and up-to-date example of setting up Vue.js with TypeScript. The typical tutorials out there either are outdated or rely on specific configurations that don't apply universal ...

Analyzing the value of a tab with Protractor测试

Below is my HTML code showcasing a list of tabs: <mat-tab-group> <mat-tab label="A"> <app-A></app-A> </mat-tab> <mat-tab label="B"> <app-B></app-B> </mat ...

Having trouble with the CSS `not` selector?

Below is the code snippet I experimented with XHTML <div> <span>Span1</span> <span>Span12</span> <span>Span13</span> </div> <div> <span>Span1</span> <span> ...

filtering elements with selectable functionality in jQuery UI

I'm trying to exclude the <div> children from being selected within this list item and only select the entire <li>. The structure of the HTML is as follows: <ul id="selectable"> <li> <div id="1"></div> ...

Fill your HTML form effortlessly using data from Google Sheets

I am relatively new to this topic, but I'm seeking a solution to populate an Apps Script Web App HTML dropdown form with names directly from a Google Spreadsheet. At the moment, I've managed to retrieve an array of names from column A in my sprea ...

transfer information using dropzone

I am currently working with Dropzone and have implemented the following code: <form action="#" class="dropzone" ></form> Within the JavaScript code, the dropzone function is set to upload images only when a button with the id "startUpload" i ...

What is the best way to ensure that all the divs within a grid maintain equal size even as the grid layout changes?

I have a grid of divs with dimensions of 960x960 pixels, each block is usually 56px x 56px in size. I want to adjust the size of the divs based on the changing number of rows and columns in the grid. Below is the jQuery code that I am using to dynamicall ...

What is the best way to determine the size of a returned element in React?

How can I determine if the description of {book.volumeInfo.description} is empty or not? If the length of {book.volumeInfo.description} is greater than zero, display it; otherwise, show "Book without description". I am unsure of the correct way to get the ...

Using npm to add a SOAP client with authentication headers

I am currently working on integrating the npm soap package to establish endpoints for a remote server that can be accessed via Angular 4. Despite going through the documentation, I still find myself uncertain about its practical application. The WSDL provi ...

Is it possible for me to invoke an anonymous self-executing function from a separate scope?

I'm having an issue with calling the hello() function in ReactJS. When I try to call it, I receive an error message that says "Uncaught ReferenceError: hello is not defined". How can I go about resolving this error? This is a snippet from my index.ht ...