vscode powershell running ts-node reports an error
Recurrence : In window10, ts-node is installed globally on the external CMD , and execution of ts-node -v shows that the version number is installed successfully. Open the terminal in vscode , create a new ts file and use ts-node test.ts to report an error.
ts-node : Unable to load file xxxx because running scripts is prohibited on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170. Location Line: 1 Character: 1 + ts-node 07.ts + ~~~~~~~ + CategoryInfo : SecurityError: (:)[], PSSecurityException + FullyQualifiedErrorId : UnauthorizedAccess
Reason : The script running on cmd cannot run on powershell , and the execution policy of powershell restricts its execution.
Solution : View the execution policy of powershell and change the execution policy for the user
Execute the command to view the execution policy: Get-ExecutionPolicy -List
Briefly explain:
userPolicy — Computer current user group policy settings
Process — This scope only affects the current powershell session, the execution policy is not saved in the registry, and it is deleted when it is closed. (Refer to sessionStorage to understand)
CurrentUser — The execution policy affects only the current user, which is stored in the HKEY_CURRENT_USER registry
LocalMachine — Execution policy affects all users on the current computer and is saved in the registry
Change the execution policy of CurrentUser
Set-ExecutionPolicy -ExecutionPolicy <PolicyName> -Scope <scope>
Change CurrentUser to RemoteSigned here .
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Review the execution strategy again
It’s ok now
Read More:
- How to Solve Vscode terminal error (ts -v)
- [Solved] Hbase …ERROR: Unable to read .tableinfo from file:/hbaseData/data/default/table1/xxxx
- VSCode Unable to find custom header file directory: fatal error: no such file or directory
- [Solved] Vscode error: Unable to resolve resource walkThrough://vscode_getting_started_page
- [Solved] VScode Run C++ File Error: fatal error:opencv2\core.hpp:No such file or diretory
- [Solved] IDEA Error: Unable to resolve column XXXX
- VScode integrate terminal input node error [How to Solve]
- Error while trying to run project:unable to start debugging.the debugger is not properly installed. run setup to install or repa
- [Solved] tsc execute error in VSCode Terminal
- VSCode Terminal Execute tsc Commands Error [Solved]
- [Solved] Error: unable to perform an operation on node ‘rabbit@DESKTOP-xxx‘. Please see diagnostics informa
- [Solved] K8s Error: ERROR: Unable to access datastore to query node configuration
- [Solved] cnpm: Cannot load the file C:\Users\Raytine\AppData\Roaming\npm\cnpm.ps1 because running scripts is prohibited on this system
- [Solved] Rabbitmq Server Error: unable to perform an operation on node ‘rabbit@nscczzms‘. P
- [Solved] React Native Red screen Error: Unable to load script from assets
- [Solved] VScode Error: PS D:\vscode> cd “d:\vscode\“ ; if ($?) { g++ tempCodeRunnerFile.cpp -o tempCodeRunn
- NPM run dev Error Module build failed: Error: Cannot find module ‘node-sass’
- Node Kubelet Error: node “xxxxx“ not found [How to Solve]
- [Solved] VScode sftp Code synchronizate Error: Error: No such file
- [Solved] fatal error C1083: Could Not Open Unable to open include file:“stdint.h”: No such file or directory