Problems with nodejs require files

problem description

the structure of the project is as follows
there are index.js and https folders in the root directory, and handler.js and proxy.js; in the https folder
proxy.js as follows

const init=()=>{
    //code
}
const proxyAdd=()=>{
    //code
}
module.exports.proxy={
    init,
    proxyAdd
}

in index.js, I use the following code to introduce and call no problem. You can see that there are two methods in printing proxy:

\\index.js
const {proxy}=require("./https/proxy")

\\
proxy.init()

but there is something wrong with introducing proxy.js into handler.js

\\handler.js
const {proxy}=require("./proxy")
proxy.proxyAdd() \\proxy ={}

here the breakpoint finds that proxy is an empty object < del > ~ < / del > ~ excuse me why?

Mar.23,2022

well, how strange


clear your processing logic code. Whether the simple export null function can reproduce this problem

Menu