@shopify/shopify-api jws 依赖不起作用

Emm*_*cea 5 shopify shopify-app shopify-api-node shopify-api

我是 Shopify 的新手,当我尝试使用 @shopify/shopify-api 时遇到问题。我正在从 API 导入此属性。

import Shopify from '@shopify/shopify-api'
Run Code Online (Sandbox Code Playgroud)

当我进行导入时,出现下一个错误。

Uncaught TypeError: util.inherits is not a function
at node_modules/jsonwebtoken/node_modules/jws/lib/data-stream.js (data-stream.js:39:6)
at __require (chunk-IGMYUX52.js?v=cd28f3b3:40:50)
at node_modules/jsonwebtoken/node_modules/jws/lib/sign-stream.js (sign-stream.js:3:18)
at __require (chunk-IGMYUX52.js?v=cd28f3b3:40:50)
at node_modules/jsonwebtoken/node_modules/jws/index.js (index.js:2:18)
at __require (chunk-IGMYUX52.js?v=cd28f3b3:40:50)
at node_modules/jsonwebtoken/decode.js (decode.js:1:11)
at __require (chunk-IGMYUX52.js?v=cd28f3b3:40:50)
at node_modules/jsonwebtoken/index.js (index.js:2:11)
at __require (chunk-IGMYUX52.js?v=cd28f3b3:40:50)
Run Code Online (Sandbox Code Playgroud)

所以我转到文件中发生错误的行:

node_modules/jsonwebtoken/node_modules/jws/lib/data-stream.js
Run Code Online (Sandbox Code Playgroud)

我发现错误是节点包中的一个属性

如果您在此处看不到图像,请查看代码行。

util.inherits(DataStream, Stream);
Run Code Online (Sandbox Code Playgroud)

所以我查阅了节点文档,发现该方法不鼓励使用,但并未弃用,因此它应该可以工作。

如果您看不到图像,这里是该方法的描述。

不鼓励使用util.inherits()。请使用 ES6 class 和 extends 关键字来获得语言级别的继承支持。另请注意,这两种样式在语义上不兼容。

将原型方法从一个构造函数继承到另一个构造函数。构造函数的原型将被设置为从创建的新对象 superConstructor

这主要是在Object.setPrototypeOf(constructor.prototype, superConstructor.prototype). 作为额外的便利, superConstructor可通过constructor.super_ 酒店抵达。

有问题的包名为 jws,我不太确定这个包的用途,我有修改文件并使用原型继承替换该代码行的想法,但我不知道这样做有多好。此外,我必须对每个存在该问题的文件执行此操作,我还没有在互联网上找到有关此问题的任何信息。