6

关于 Node 引入的问题

 2 years ago
source link: https://www.v2ex.com/t/839006
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

V2EX  ›  Node.js

关于 Node 引入的问题

  yuhangch · 7 小时 36 分钟前 · 863 次点击

对 node 不太熟,想用这个包下载弹幕玩玩,弹幕的解码器文档如下

https://github.com/Mr-Quin/bilibili-api#Protobuf

import { decodeDanmaku } from '@mr-quin/bilibili-api/proto'

const buffer = await biliRequest((api) => api.videoDanmakuProto, {
    vid: 'BV1vE411s7kX',
})
const danmaku = buffer.map(decodeDanmaku)

下面有这么一句注释

This is not done internally because the protobuf schema file is quite big and should only be imported when needed.

自己用的时候使用

import { decodeDanmaku } from '@mr-quin/bilibili-api/proto'

提示找不到 proto ,IDE 的 quick fix 之后,import 语句变为

import {decodeDanmaku} from "@mr-quin/bilibili-api/dist/protobuf/js/parser";

此时可以正常使用了,请 v 友帮忙解释下为什么?


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK