![](/img/trans.png)
[英]Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './dist/types/single-spa-layout-interface' is not defined by "exports" in
[英]Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './src/util/Constants.js' is not defined by \"exports\"
我在編寫我的不和諧機器人時遇到了問題。 每當我運行此代碼時:
const Constants = require('discord.js/src/util/Constants.js')
Constants.DefaultOptions.ws.properties.$browser = `Discord iOS`
我一直收到這個錯誤。
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './src/util/Constants.js' is not defined by \"exports\" in /home/runner/VerifyBot/node_modules/discord.js/package.json
我正在使用節點 v12.18.4 和 discord.js v12.3.1。 有任何想法嗎?
正如錯誤所暗示的那樣,您的 require 語句中的子路徑未在 Discord JS 的package.json 中定義。 如果要獲取常量,可以使用以下代碼行來實現:
const { Constants } = require('discord.js');
或者,以下方法也適用:
const Discord = require('discord.js');
const Constants = Discord.Constants;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.