简体   繁体   English

当我尝试运行节点 js 文件时,出现 ReferenceError: XMLHttpRequest is not defined

[英]When I tried to run a node js file .I am getting ReferenceError: XMLHttpRequest is not defined

From google search I came to know that it is because XMLHttp not installed(many sites are saying the same reason).I installed that using install xmlhttprequest.从谷歌搜索我知道这是因为没有安装 XMLHttp(许多网站都说同样的原因)。我使用 install xmlhttprequest 安装了它。 I guess it is installed properly.Again the same error is showing.How can I solve that problem.Since I am on my learning period,I don't have much idea about debugging.I have added the code a little and the error pattern obtained while running in terminal.Can somebody give what is happening and what should i do to overcome this error我猜它安装正确。再次显示相同的错误。我该如何解决这个问题。由于我处于学习期,我对调试没有太多想法。我已经添加了一点代码和错误模式在终端中运行时获得。有人可以给出正在发生的事情,我应该怎么做才能克服这个错误

const setEditModal = (isbn) => {
    const xhttp = new XMLHttpRequest();

    xhttp.open("GET", `http://localhost:3000/book/${isbn}`, false);
    xhttp.send();
               

Error:错误:

ReferenceError: XMLHttpRequest is not defined
            at loadBooks (C:\Users\Hp\book-list.js:38:19)
            at Object.<anonymous> (C:\Users\Hp\book-list.js:73:1)
      

Ok you installed it but it seams that you did't import it:)好的,您安装了它,但接缝表明您没有导入它:)

const {XMLHttpRequest} = require("xmlhttprequest");

or或者

import {XMLHttpRequest} from 'xmlhttprequest'

depending of your version取决于你的版本
documentation here文档在这里

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用打字稿时出现“ Uncaught ReferenceError:未定义角度” - I am getting “Uncaught ReferenceError: angular is not defined” when using typescript 为什么我得到“ReferenceError:getElementById未定义”? - Why am I getting “ReferenceError: getElementById is not defined”? 为什么收到“ ReferenceError:未定义$ cacheFactory” - Why am I getting “ReferenceError: $cacheFactory is not defined” 为什么我得到一个ReferenceError:未定义 - Why am I getting a ReferenceError: not defined 从节点js请求到Php文件,我发现错误404未找到,我尝试了所有可能的路径,但没有得到它 - Request to Php file from node js and i am getting the error 404 not found and i tried every possible path but not getting it 参考错误:当我尝试通过 nodemon myWebJs.js 运行时,$ 未定义......一切都在浏览器上运行..只是节点不工作 - referenceError: $ is not defined when i try to run thru nodemon myWebJs.js … everything works on browser..just node is not working 当我尝试读取 Firebase 上的数据时,出现“未捕获的 ReferenceError:firebase 未定义”错误 - I am getting "Uncaught ReferenceError: firebase is not defined" error when i try to read my datas on Firebase 为什么我会收到 ReferenceError: AbortController is not defined in Discord.js v13? - Why am I getting a ReferenceError: AbortController is not defined in Discord.js v13? 当我尝试在“node.js”中运行这行代码时,我收到以下错误 - When I try to run this line of code in “node.js”, I am getting the following error 未捕获的 ReferenceError:未定义加载模型。 使用 PHP 和 JavaScript 文件类型=模块时出现此错误 - Uncaught ReferenceError: loadmodel is not defined. I am getting this error while working with PHP and JavaScript file type=module
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM