问题描述
我知道浏览器中有一些可以使用require的工具,就像在Node中一样。如果在控制台中出现参考错误,提示require未定义,该怎么办?
当我写“ const path = require('path');”时我收到消息:
[nodemon] restarting due to changes...
[nodemon] starting `node server`
(node:9704) ExperimentalWarning: The ESM module loader is experimental.
file:///C:/Users/Sabino/Documents/reactAppDemo/server/index.js:1
const path = require('path');
^
ReferenceError: require is not defined
at file:///C:/Users/Sabino/Documents/reactAppDemo/server/index.js:1:14
at ModuleJob.run (internal/modules/esm/module_job.js:146:37)
at async Loader.import (internal/modules/esm/loader.js:182:24)
at async Object.loadESM (internal/process/esm_loader.js:84:5)
[nodemon] app crashed - waiting for file changes before starting...
有人知道为什么会这样吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)