Skip to content

Instantly share code, notes, and snippets.

@nickytonline
Last active January 27, 2016 20:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickytonline/cba81dfd27032f8daf27 to your computer and use it in GitHub Desktop.
Save nickytonline/cba81dfd27032f8daf27 to your computer and use it in GitHub Desktop.
A Task for Windows Task Scheduler to run local-npm
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2016-01-21T08:54:47.1813619</Date>
<Author>YOUR_DOMAIN\YOUR_USER</Author>
<Description>Runs local-npm a local version of npm that grabs packages from it's server if not already fetched. This essentially allows you to run npm offline, assuming you've installed the packages you need at least once.</Description>
</RegistrationInfo>
<Triggers>
<LogonTrigger>
<Enabled>true</Enabled>
</LogonTrigger>
</Triggers>
<Principals>
<Principal id="Author">
<UserId>YOUR_DOMAIN\YOUR_USER</UserId>
<LogonType>InteractiveToken</LogonType>
<RunLevel>LeastPrivilege</RunLevel>
</Principal>
</Principals>
<Settings>
<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
<StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
<AllowHardTerminate>true</AllowHardTerminate>
<StartWhenAvailable>true</StartWhenAvailable>
<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
<IdleSettings>
<StopOnIdleEnd>true</StopOnIdleEnd>
<RestartOnIdle>false</RestartOnIdle>
</IdleSettings>
<AllowStartOnDemand>true</AllowStartOnDemand>
<Enabled>true</Enabled>
<Hidden>false</Hidden>
<RunOnlyIfIdle>false</RunOnlyIfIdle>
<WakeToRun>false</WakeToRun>
<ExecutionTimeLimit>PT0S</ExecutionTimeLimit>
<Priority>7</Priority>
</Settings>
<Actions Context="Author">
<Exec>
<Command>powershell.exe</Command>
<Arguments>-windowstyle hidden -command local-npm</Arguments>
</Exec>
</Actions>
</Task>
@nickytonline
Copy link
Author

Here's a great article on "Offline installation of npm packages"
and with that...

Instructions:

  1. install local-npm globally via npm i local-npm -g
  2. set your npm registry to point to the local-npm server via npm set registry http://127.0.0.1:5080/
  3. Replace YOUR_DOMAIN\YOUR_USER in this file with your real domain and user name.
  4. import this scheduled task into your Task Scheduler in Windows.
  5. Run the task or logout and log back in again.
  6. Navigate to http://127.0.0.1:5080/_browse in a browser. If it loads you're in business.
  7. Happy offline "npm"ing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment