使用内置模块报错
huangweikuna opened this issue · 0 comments
huangweikuna commented
第一步
const { url } = require('url');
浏览器报错
Uncaught ReferenceError: require is not defined
网上查找原因之后修改为
import { createRequire } from 'module';
const require = createRequire(import.meta.url);
const { url } = require('url');
浏览器报错
Uncaught SyntaxError: The requested module '/@id/__vite-browser-external:module' does not provide an export named 'createRequire'
如何才能正常引用呢= =