【发布时间】:2019-05-20 03:59:51
【问题描述】:
我使用 npm install waypoints 安装了航点库并使用
添加了类型npm install --save @types/waypoints。
我收到错误消息 /node_modules/@types/waypoints/index.d.ts' is not a module。
Using waypoints.js in Angular 4 application
讨论了同样的问题。用户有同样的错误。 一条评论建议“使用 export package_name = package_name。这应该可行”我不知道如何实现。
我尝试添加
export = waypoints
export as namespace waypoints;
declare namespace waypoints {
}
import * as Waypoint from 'waypoints';
当我尝试导入航点时,我没有收到任何错误。 但如果我再添加一个像这样的航点:
let waypoint = new Waypoint.Waypoint({
element: document.querySelector("#p5"),
handler: function () {
},
});
我得到另一个错误 ->
找不到模块:错误:无法解析“航点”
【问题讨论】:
-
可能
Waypoint导入路径错误。您应该导入Waypoint模块,而不是类型定义。不要太相信自动导入 -
你能解决这个问题吗?
标签: angular typescript types npm-install waypoint