javascript - 修复 : Use global instead of window

标签 javascript node.js npm runkit

我正在尝试 runkit.com 中的一个组件。从图像中可以看出,平台告诉我......

Fix: Use global instead of window. RunKit is a node environment, so window and other browser features won’t exist. If you’re just trying to access the global object, you can simply use global instead.

这是粘贴的代码:

var window = {};
const QueryQl = require("queryfilters/queryql")
var q = new QueryQl();
q.json({
    'ciao': 'mondo'
});
q.getQueryString();

Fix: Use global instead of window.

我该如何解决这个问题?

最佳答案

修复很简单。只需替换这个

window.module = window.module || {};

用这个:

global.module = global.module || {};

在模块中。

关于javascript - 修复 : Use global instead of window,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48126407/

相关文章:

javascript - 并行 API 请求的异步模块错误

javascript - 穆尔特 : Setting different destinations in the destination Property

javascript - 如何开始使用 html2canvas

node.js - 如何使用 yarn 正确安装 expo-cli?

javascript - 从 SvelteKit load() 函数导出 Prop

javascript - 具有多个组件渲染的动态加载器组件

javascript - 从 2 个数组创建一个字典( MAP )

javascript - 如何在 Javascript 中的 Constructor.prototype 中定义本地函数

php - 带有 express 和 mysql 的 Node.js API - 重新定义获取的参数以进行正确的列搜索

javascript - NodeJS 与 connect-busboy 发生错误, "TypeError: Cannot call method ' 未定义”