源代碼是:const Sequelize = require('sequelize');const sequelize = new Sequelize(process.env["DSN"]);當(dāng)試圖通過(guò)節(jié)點(diǎn)執(zhí)行時(shí)(我堅(jiān)持,我不是試圖在我的瀏覽器中執(zhí)行此代碼),我得到:$ node Sequelize.jsfile:///Users/snwfdhmp/project/Sequelize.js:1const Sequelize = require('sequelize'); ^ReferenceError: require is not defined at file:///Users/snwfdhmp/project/Sequelize.js:1:19 at ModuleJob.run (internal/modules/esm/module_job.js:138:23) at async Loader.import (internal/modules/esm/loader.js:178:24)為什么會(huì)發(fā)生這種情況?互聯(lián)網(wǎng)上的每篇文章都說(shuō)“不要在瀏覽器中使用 require()”,但我沒(méi)有使用瀏覽器。我在 macOS 10.15.5 上使用節(jié)點(diǎn) v14.4.0。
節(jié)點(diǎn): 引用錯(cuò)誤: 要求未定義
ABOUTYOU
2022-09-29 10:23:37