I found the following code online that is used to emulate the browser XMLHttpRequest object.
var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
var xhr = new XMLHttpRequest();
source: https://www.npmjs.com/package/xmlhttprequest
But when I run the file file text.js which only has those 2 lines on node, I get the following error in the console:
Error: Cannot find the module 'xmlhttprequest'
Question: What might I be doing wrong?
在您的项目目录中,打开一个bash并输入
npm i xmlhttprequest
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.