ES import Service from 'node-windows' #357
-
I'm not sure if I fully understand the difference between const Service = require('node-windows').Service which is documented in the readme and the newer es6 syntax using import. So after trial and several errors, I managed to re-write the sample code to read as follows: import nodeWindows from 'node-windows' This worked without throwing an es6 error and after looking at Task Manager, I was able to confirm my server is now running. Does anyone with better understanding of the syntax want to confirm or correct my understanding? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I think you also could do this (untested, there might be a special syntax CommonJS libraries need to be written in to allow this): import { Service } from 'node-windows'; Note: When this library was written (and the maintainer had time to keep things up to date), ESM wasn't a thing yet, which is why none of the documentation talks about that format. |
Beta Was this translation helpful? Give feedback.
I think you also could do this (untested, there might be a special syntax CommonJS libraries need to be written in to allow this):
Note: When this library was written (and the maintainer had time to keep things up to date), ESM wasn't a thing yet, which is why none of the documentation talks about that format.