Compile typescript file on offline windows 10

daryush salahshur 136 Reputation points
2021-11-19T09:33:51.853+00:00

I want to run TS offline, it gets an error, I transferred the npm folder from the computer that compiles it correctly to the offline computer
Offline computer Does not compile the simplest TS line
The Error is:
PS E: \ spfX \ TypeScript> tsc index.ts
tsc: File C: \ Users \ moon \ AppData \ Roaming \ npm \ tsc.ps1 cannot be loaded. The file C: \ Users \ moon \ AppData \ Roaming \ npm \ tsc.ps1 is not digitally signed. You can not run this script on the current system. For more information about running scripts and setting execution
I went the different ways that are on the Internet.
Both computers I have on the Internet are Windows 10

Does anyone have any tips other than solutions like the one below?
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned

Best Regards,
Daryush

Microsoft 365 and Office | SharePoint | Development
0 comments No comments
{count} votes

Accepted answer
  1. RaytheonXie_MSFT 40,471 Reputation points Microsoft External Staff
    2021-11-22T02:37:36.607+00:00

    Hi @daryush salahshur ,
    When you try to run a PowerShell script that has not been signed by a trusted publisher, you may get the following security error:
    "script.ps1 :File path\script.ps1 cannot be loaded. The file path\script.ps1 is not digitally signed. You cannot run this script on the current system."

    This security error can occur when the PowerShell's execution policy is set to Allsigned or Remotesigned and the script isn't signed.

    There are different methods to overcome this error. You may choose to either sign the PowerShell script, change the execution policy, bypass the policy or unblock the file so that it can run once on that session.

    First of all check your execution policy using the cmdlet Get-ExecutionPolicy -list

    PS C:\> Get-ExecutionPolicy -list 	  
                Scope     ExecutionPolicy  
                -----     ---------------  
        MachinePolicy     Undefined  
           UserPolicy     Undefined  
              Process     Undefined  
          CurrentUser     Undefined  
         LocalMachine     RemoteSigned  
    

    The default execution policy is RemoteSigned. The easiest but unsecure method of getting rid of this error message is to change the ExecutionPolicy using the SetExecutionPolicy cmdlet. The following command sets the execution policy to unrestricted.

    Set-ExecutionPolicy unrestricted  
    

    Press Y to confirm the change when prompted. The policy change is updated in the registry and will remain until you change it again. Instead of changing the execution policy permanently you could set a different policy for a single PowerShell session. This is done using the ExecutionPolicy parameter of powershell.exe

    powershell.exe -executionpolicy -bypass  
    

    If you trust the contents of the script are safe then you can unblock it to run on your session using the Unblock-File cmdlet

    Unblock-File -Path C:\Users \ moon \ AppData \ Roaming \ npm\tsc.ps1  
    

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


    2 people found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.