Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 找不到模块_Javascript - Fatal编程技术网

Javascript 找不到模块

Javascript 找不到模块,javascript,Javascript,正在尝试执行一些经济命令,当前正在尝试执行将消息作者拥有的硬币总数发送给消息作者的命令。我继续出现“找不到模块”错误。我试图寻找这个错误,但似乎找不到解决办法 我的文件结构- const{richembd}=require(“discord.js”); let coins=require(“../coins.json”); module.exports={ 名称:“硬币”, 描述:“显示你有多少硬币”, 类别:“经济”, 运行:异步(客户端、消息、参数)=>{ //硬币 如果(!coins[me

正在尝试执行一些经济命令,当前正在尝试执行将消息作者拥有的硬币总数发送给消息作者的命令。我继续出现“找不到模块”错误。我试图寻找这个错误,但似乎找不到解决办法

我的文件结构-

const{richembd}=require(“discord.js”);
let coins=require(“../coins.json”);
module.exports={
名称:“硬币”,
描述:“显示你有多少硬币”,
类别:“经济”,
运行:异步(客户端、消息、参数)=>{
//硬币
如果(!coins[message.author.id]){
硬币[message.author.id]={
硬币:0
};
}
让uCoins=coins[message.author.id].coins;
让coinEmbed=new RichEmbed()
.setAuthor(message.author.username)
.setcolor(“随机”)

艾德菲尔德先生(“根据您链接的文件结构,您的
require
正在
commands
文件夹中查找
coins.json
,因为您只在文件名前加了一次
。/
。为了获取您的文件,请在文件名前加上
。/../
,这样它会出现在两个文件夹中。您的行如下所示:


如果是由于路径不正确,您可以使用下面的代码。它会在您的代码中的任何地方找到json文件

const{join}=require(“路径”);
让coins=require(`${join(process.cwd(),“coins.json”)}`);

Try
let coins=require(“..../../coins.json”);
谢谢你,我还是JS的业余爱好者。这对我以后的任何命令都有帮助
const { RichEmbed } = require("discord.js");
let coins = require("../coins.json");

module.exports = {
    name: "coins",
    descriptions: "shows how many coins you have",
    category: "Economy",
    run: async (client, message, args) => {
        //coins
        if(!coins[message.author.id]){
            coins[message.author.id] = {
                coins: 0
            };
        }
        let uCoins = coins[message.author.id].coins;

        let coinEmbed = new RichEmbed()
            .setAuthor(message.author.username)
            .setcolor("RANDOM")
            .addField("As per the file structure you linked, your 
require
is looking for the
coins.json
in the
commands
folder, as you only prefixed the file name with
../
once. In order to get your file, prefix the name with
../../
, so it goes up two folders. Your line would then look like this:

let coins = require("../../coins.json");