繁体   English   中英

未捕获的类型错误:无法解析模块说明符“tslib”。 相对引用必须以“/”、“./”或“../”开头

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

拜托,我开始学习 npm。 如果我想安装“@fullcalendar”并使用它,我会收到错误:“未捕获的类型错误:无法解析模块说明符“tslib”。相对引用必须以“/”、“./”或“../”开头。 "

我有这个结构: www/templates/node_modules/www/templates/assets/calendar.js

这是我的 calendar.js 文件的开始:

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

在导入 {Calendar} 的那一刻,它的抛出错误。 在@fullcalendar/core/main.js 我看到:

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';

但我认为 tslib (和其他导入库)的方式是不正确的。 但是 tslib 在目录 www/templates/node_modules/tslib 中。 我不想编辑安装的 package (我认为这不是正确的方法)。 我可以在 npm 配置中设置路径吗? 有可能的? 或者最好的方法是什么?

谢谢。

你的进口是错误的。 您不需要节点模块的完整路径。 您可以像这样导入它们:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:未捕获类型错误:无法解析模块说明符“web3”。 相对引用必须以“/”、“./”或“../”开头 Firebase 未捕获的类型错误:无法解析模块说明符“firebase/app”。 相对引用必须以“/”、“./”或“../”开头 未使用 node.js:未捕获类型错误:无法解析模块说明符“三”。 相对引用必须以“/”、“./”或“../”开头 未捕获的类型错误:无法解析模块说明符“firebase/app”。 相对引用必须以“/”、“./”或“../”开头 Uncaught TypeError:无法解析模块说明符“…”。 相对引用必须以“ /”、“./”或“ ../”开头。 在(索引):1 未捕获的类型错误:无法解析模块说明符“fs”。 相对引用必须以“/”、“./”或“../”开头 未捕获的类型错误:无法解析模块说明符“提示同步”。 相对引用必须以“/”、“./”或“../”开头 未捕获的类型错误:无法解析模块说明符“表单数据”。 相对引用必须以“/”、“./”或“../”开头 为什么会出现 Uncaught TypeError:无法解析模块说明符“firebase”。 相对引用必须以“/”、“./”或“../”开头? 无法解析模块说明符“sortablejs”。 相对引用必须以“/”、“./”或“../”开头
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM