Node.js: how to reload module

前端 未结 3 1131
走了就别回头了
走了就别回头了 2021-02-04 03:37

I am new to NodeJS so probably I am doing some mistakes.

I have written a bunch of code in an external file called myapp. I start NodeJS for windows and from the interpr

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-04 04:37

    I solved this by adding the following above the require statements:

    Object.keys(require.cache).forEach(function(key) { delete require.cache[key] })
    

    Taken from @Dancrumb's comment here

提交回复
热议问题