1. Open Task Scheduler (Win + R, taskschd.msc)
  2. Go to Actions > Create Basic Task...
  3. Enter a name and description
  4. Select trigger, e.g. Daily, One time, When I log on...
  5. Configure action:
    • Type: Start a program
    • Program/script: npm
    • Arguments: run <script-name>, e.g. run scrape
    • Start in: directory where package.json is located, e.g. C:\projects\hello
  6. Click Finish and test your action

Additionally, if you want the task to run in the background, make sure to select "Run whether user is logged on or not" under General properties for the task.

  • windows
  • npm