Visual studio code terminal, how to run a command with administrator rights?

前端 未结 4 897
挽巷
挽巷 2020-12-04 20:34

The new version 1.2.0 include a terminal, but when I try to install any pack with node I get the npm ERR! code EPERM that I usually solve right clicking and running it as ad

4条回答
  •  臣服心动
    2020-12-04 21:09

    Here's what I get.

    I'm using Visual Studio Code and its Terminal to execute the 'npm' commands.

    Visual Studio Code (not as administrator)
    PS g:\labs\myproject> npm install bootstrap@3

    Results in scandir and/or permission errors.

    Visual Studio Code (as Administrator)
    Run this command after I've run something like 'ng serve'

    PS g:\labs\myproject> npm install bootstrap@3

    Results in scandir and/or permission errors.

    Visual Studio Code (as Administrator - closing and opening the IDE)
    If I have already executed other commands that would impact node modules I decided to try closing Visual Studio Code first, opening it up as Administrator then running the command:

    PS g:\labs\myproject> npm install bootstrap@3

    Result I get then is: + bootstrap@3.3.7
    added 115 packages and updated 1 package in 24.685s

    This is not a permanent solution since I don't want to continue closing down VS Code every time I want to execute an npm command, but it did resolve the issue to a point.

提交回复
热议问题