如何在NodeJS中使用Javascript窗口?

如何在NodeJS中使用Javascript窗口?,javascript,node.js,window,shopify,Javascript,Node.js,Window,Shopify,我正在尝试使用本教程构建嵌入式Shopify应用程序: 在“使用OAuth进行身份验证”一节中,作者编写了以下代码: // If the current window is the 'parent', change the URL by setting location.href if (window.top == window.self) { window.location.assign(permissionUrl); // If the current window is the

我正在尝试使用本教程构建嵌入式Shopify应用程序:

在“使用OAuth进行身份验证”一节中,作者编写了以下代码:

// If the current window is the 'parent', change the URL by setting location.href
if (window.top == window.self) {
  window.location.assign(permissionUrl);

  // If the current window is the 'child', change the parent's URL with Shopify App Bridge's Redirect action
} else {
  const app = createApp({
    apiKey: apiKey,
    shopOrigin: shopOrigin
  });

  Redirect.create(app).dispatch(Redirect.Action.REMOTE, permissionUrl);
}
问题是,它是指JavaScript窗口对象。但是这里使用的是节点JS

我曾尝试使用jsdom来使用JavaScript窗口对象,但它似乎无法正常工作

因此有两个问题:

当代码本身是关于NodeJS时,作者为什么使用JavaScript窗口


我如何让它在NodeJS中工作?

这篇文章中没有提到使用Node.js为什么说代码是关于NodeJS的?因为在文章后面使用了OAuth,我认为这里使用了它的NodeJS。此外,教程在Shopify中使用always NodeJS在该段代码之前,有一段以“因为嵌入式应用程序加载在iframe[…]中”开头-嵌入式iframe仅在浏览器环境中出现。接下来的文本将讨论如何通过转义iframe从父级执行重定向。然后是检查代码是否在iframe中运行并使用特定于浏览器的调用的代码。因此,我不认为这与NodeJS有关。我不是Shopify专家,但这篇文章显然是关于前端发生的事情,甚至没有使用
npm
,因为它说明
npm
是一种替代方案