我正在尝试在我的React项目中使用一个包,该包将允许我进行API调用(axios、node-fotch、get等)
如果未安装这些软件包,应用程序将正常运行。当它们中的任何一个被安装并在代码中调用时,我将面临如下错误:
忽略这些警告,我认为问题的根源在于以下输出:
Failed to compile.
Module build failed: UnhandledSchemeError: Reading from "node:buffer" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.
我什么都试过了。已重新安装node_modules。创建了一个干净的测试应用程序,并在那里进行了尝试。我也做了研究,没有找到任何相关的、明确的解决方案。没有任何帮助。
我做错了什么??
DomException文件内容:
/*! node-domexception. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
if (!globalThis.DOMException) {
try {
const { MessageChannel } = require('worker_threads'),
port = new MessageChannel().port1,
ab = new ArrayBuffer()
port.postMessage(ab, [ab, ab])
} catch (err) {
err.constructor.name === 'DOMException' && (
globalThis.DOMException = err.constructor
)
}
}
module.exports = globalThis.DOMException
npm版本:8.5.5
节点版本:16.15.0