kessler / node-regedit

Read, Write, List and do all sorts of funky stuff to the windows registry using node.js and windows script host
MIT License
279 stars 45 forks source link

How do I use ES6 syntax? #114

Closed ll21121 closed 7 months ago

ll21121 commented 1 year ago

import { list } from "regedit"; list([path], function(error:any, result:any){ ... })

error msg:
TypeError: $u.inherits is not a function at node_modules/stream-slicer/index.js (index.js:4:4) at __require (chunk-JEXKZRFY.js?v=6827b305:12:50) at node_modules/regedit/index.js (index.js:7:22) at __require (chunk-JEXKZRFY.js?v=6827b305:12:50) at index.js:573:1 (匿名) @ index.ts:107

I'm a back-end developer. I don't know much about this

kessler commented 1 year ago

are you using typescript ?

ll21121 commented 1 year ago

I used cool-admin template, https://show.cool-admin.com/。 vue +ts + vite image

kessler commented 1 year ago

stream slicer is a very old lib I wrote a long time ago (and ditched it a long time ago for better modules like split), anyways:

image

line 4 here just uses the built in nodejs util.inherits and while it's legacy, it's not deprecated... so honestly, this shouldn't happen.

Could you try running your code using node in command line (and nothing else no typescript or other things) see if it works?

ll21121 commented 1 year ago

image look, everything is ok。 but how to use "import" , can you write a simple example?

kessler commented 1 year ago

this should work:

import { promisified as regedit } from 'regedit'

async function main() {
  await regedit.list(...)
}

main()