ลอง vue –version เจอ windows บอก UnauthorizedAccess

หลังจากย้ายเครื่องใหม่มา ลองมาทำ Slide Project ด้วย Vue เจอ Error

PS D:\2WarRoom\RedmineVersionViewer> vue --version
vue : File C:\Users\Chatr\AppData\Roaming\npm\vue.ps1 cannot be loaded because running scripts is disabled on this
system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ vue -version
+ ~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

อันนี้เป็น Error PowerShell นะ เห็นใน Stackoverflow บอกให้ลบไฟล์ออก 55 ไม่ต้องนะ ใช้คำสั่งนี้

Set-ExecutionPolicy RemoteSigned 

เพราะโดย Default Windows มันจะไม่ยอมให้เรา Run ไฟล์ PowerShell ถ้าจะปรับให้ทำงานได้ มีหลายแบบ AllSigned / Bypass / RemoteSigned / Restricted เป็นต้น โดยผมจะเลือก RemoteSigned ดูจะเป็นสัดส่วนที่ลงตัวครับ

เอาเฉพาะ User เรา โดยเพิ่ม scope เข้าไปครับ

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

ลอง Run คำสั่งเดิมอีกรอบ

PS D:\2WarRoom\RedmineVersionViewer> vue --version
@vue/cli 5.0.8

Reference


Discover more from naiwaen@DebuggingSoft

Subscribe to get the latest posts to your email.