Uncaught TypeError: URL is not a constructor using WHATWG URL object support for electron

前端 未结 4 874
自闭症患者
自闭症患者 2021-01-01 10:08

I am trying to read a file using WHATWG URL object support here

and I am getting this error: Uncaught TypeError: URL is not a constructor

here is my code:

4条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-01 10:47

    I faced the same issue, then I looked into the url module and found a solution

    For Node V6 use,

    const URL = require('url').Url;
    

    or

    const { Url } = require('url'); 
    

    If you look into the module, it exports 5 methods one of which is Url, so if you need to access Url, you can use either of the two methods

提交回复
热议问题