简体   繁体   中英

Uncaught TypeError: Failed to resolve module specifier “tslib”. Relative references must start with either “/”, “./”, or “../”

please, I started learn npm. If I want instal "@fullcalendar" and used it i get error: " Uncaught TypeError: Failed to resolve module specifier "tslib". Relative references must start with either "/", "./", or "../". "

I have this structure: www/templates/node_modules/ www/templates/assets/calendar.js

It is start of my calendar.js file:

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

other code

In the moment where is imported {Calendar} its throw error. In @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';

But i think that way to tslib (and other import libs) is incorrect. But tslib is in directory www/templates/node_modules/tslib. I dont want edit installed package (i think that is not correct way). Can I set path in npm config? It is possible? Or what is the best way?

Thanks, A.

Your imports are wrong. You don't need the full path to your node modules. You can import them like:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

Related Question Error: Uncaught TypeError: Failed to resolve module specifier "web3". Relative references must start with either "/", "./", or "../" Firebase Uncaught TypeError: Failed to resolve module specifier "firebase/app". Relative references must start with either "/", "./", or "../" Not using node.js : Uncaught TypeError: Failed to resolve module specifier "three". Relative references must start with either "/", "./", or "../" Uncaught TypeError: Failed to resolve module specifier "firebase/app". Relative references must start with either "/", "./", or "../" Uncaught TypeError: Failed to resolve module specifier “…”. Relative references must start with either “/”, “./”, or “../”. at (index):1 Uncaught TypeError: Failed to resolve module specifier "fs". Relative references must start with either "/", "./", or "../" Uncaught TypeError: Failed to resolve module specifier "prompt-sync". Relative references must start with either "/", "./", or "../" Uncaught TypeError: Failed to resolve module specifier "form-data". Relative references must start with either "/", "./", or "../" Why getting Uncaught TypeError: Failed to resolve module specifier "firebase". Relative references must start with either "/", "./", or "../"? Failed to resolve module specifier "sortablejs". Relative references must start with either "/", "./", or "../"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM